Dependency Updates
Step 6: Testing Updates
6.1 Update jest.config.js
The transformIgnorePatterns must include @amazon-devices/react-native-kepler. The package 4.0.0 uses ES module syntax in its jest/setup.js file. Without this pattern, Jest fails with SyntaxError: Cannot use import statement outside a module.
module.exports = {
preset: 'react-native',
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
transformIgnorePatterns: [
'node_modules/(?!((jest-)?react-native|@react-native(-community)?|@amazon-devices/react-native-kepler)|react-native-safe-area-context)',
],
};
6.2 Create jest.setup.js for TV mocks
RN 0.83 changes how mocks work in the test environment. Create a setup file with TV-appropriate mocks, such as the example below.
// jest.setup.js
/**
* Mock Dimensions API for TV platform
* Fire TV devices use 1920x1080 (Full HD) resolution with scale factor 1
*/
jest.mock('react-native/Libraries/Utilities/Dimensions', () => ({
get: jest.fn().mockReturnValue({
width: 1920,
height: 1080,
scale: 1,
fontScale: 1,
}),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
}));
/**
* Mock PixelRatio API for TV platform
* TV devices use scale factor of 1 (no pixel doubling)
*/
jest.mock('react-native/Libraries/Utilities/PixelRatio', () => ({
default: {
get: jest.fn().mockReturnValue(1),
getFontScale: jest.fn().mockReturnValue(1),
getPixelSizeForLayoutSize: jest.fn((layoutSize) => layoutSize),
roundToNearestPixel: jest.fn((layoutSize) => layoutSize),
},
}));
/**
* Mock NativeAnimatedModule — RN 0.83 calls 23 specific methods.
* Required for any test that triggers navigation animations.
*/
jest.mock('react-native/Libraries/Animated/NativeAnimatedModule', () => ({
__esModule: true,
default: {
startOperationBatch: jest.fn(),
finishOperationBatch: jest.fn(),
createAnimatedNode: jest.fn(),
updateAnimatedNodeConfig: jest.fn(),
getValue: jest.fn(),
startListeningToAnimatedNodeValue: jest.fn(),
stopListeningToAnimatedNodeValue: jest.fn(),
connectAnimatedNodes: jest.fn(),
disconnectAnimatedNodes: jest.fn(),
startAnimatingNode: jest.fn(),
stopAnimation: jest.fn(),
setAnimatedNodeValue: jest.fn(),
setAnimatedNodeOffset: jest.fn(),
flattenAnimatedNodeOffset: jest.fn(),
extractAnimatedNodeOffset: jest.fn(),
connectAnimatedNodeToView: jest.fn(),
disconnectAnimatedNodeFromView: jest.fn(),
restoreDefaultValues: jest.fn(),
dropAnimatedNode: jest.fn(),
addAnimatedEventToView: jest.fn(),
removeAnimatedEventFromView: jest.fn(),
addListener: jest.fn(),
removeListeners: jest.fn(),
},
}));
6.3 Fix Jest mocks for .default exports
RN 0.83 changes many internal modules to use export default. Existing Jest mocks that return plain objects without a .default property break silently, where components receive undefined at runtime.
Symptom Cannot read properties of undefined (reading 'create') across multiple test suites.
Affected modules
react-native/Libraries/StyleSheet/StyleSheetreact-native/Libraries/StyleSheet/flattenStylereact-native/Libraries/EventEmitter/NativeEventEmitterreact-native/Libraries/Utilities/Platformreact-native/Libraries/Utilities/Dimensionsreact-native/Libraries/Utilities/PixelRatioreact-native/Libraries/Utilities/useWindowDimensionsreact-native/Libraries/BatchedBridge/NativeModules
Fix pattern for object-type exports
// ❌ BEFORE (breaks in RN 0.83)
jest.mock('react-native/Libraries/StyleSheet/StyleSheet', () => ({
create: (styles) => styles,
flatten: jest.fn(),
}));
// ✅ AFTER — include __esModule and default
jest.mock('react-native/Libraries/StyleSheet/StyleSheet', () => {
const impl = {
create: (styles) => styles,
flatten: jest.fn(),
};
return { __esModule: true, default: impl, ...impl };
});
Fix pattern for function-type exports:
// For function-type default exports, return the function as default directly
jest.mock('react-native/Libraries/StyleSheet/flattenStyle', () => {
const impl = jest.fn((style) => style);
return { __esModule: true, default: impl };
});
6.4 Update test files with act() wrapping
React 19 requires state updates in tests to be wrapped in act(), such as the example below.
// ❌ BEFORE (RN 0.72)
import 'react-native';
import React from 'react';
import App from '../App';
import renderer from 'react-test-renderer';
it('renders correctly', () => {
renderer.create(<App />);
});
// ✅ AFTER (RN 0.83) — using react-test-renderer directly
import React from 'react';
import ReactTestRenderer from 'react-test-renderer';
import App from '../App';
test('renders correctly', async () => {
await ReactTestRenderer.act(() => {
ReactTestRenderer.create(<App />);
});
});
@testing-library/react-native
If you use @testing-library/react-native, the testing library handles act() internally. Don't wrap render() in ReactTestRenderer.act() because this causes "Can't access .root on unmounted test renderer" errors.
// ✅ CORRECT with @testing-library/react-native
import { render, fireEvent } from '@testing-library/react-native';
test('renders correctly', () => {
const screen = render(<App />);
expect(screen).toMatchSnapshot();
});
test('handles button press', () => {
const screen = render(<App />);
fireEvent.press(screen.getByTestId('myButton'));
expect(screen).toMatchSnapshot();
});
6.5 Fix navigation stack timer leaks
If you use react-navigation__stack, its Card.tsx file uses animation setTimeout callbacks that fire after Jest tears down the test environment.
Symptom You are trying to import a file after the Jest environment has been torn down
Fix: add to affected test files
beforeEach(() => jest.useFakeTimers());
afterEach(() => {
jest.runOnlyPendingTimers();
jest.useRealTimers();
});
6.6 Fix isolatedModules type export errors
If TypeScript reports TS1205: Re-exporting a type when 'isolatedModules' is enabled requires using 'export type', update your export type like the example below.
// ❌ BEFORE
export { Cookie } from './types/CookieManagerTypes';
// ✅ AFTER
export type { Cookie } from './types/CookieManagerTypes';
6.7 Update snapshots
After all test fixes, regenerate snapshots.
# Run tests to see failures
npm test
# Update all snapshots
npm test -- -u
Review changes. Expected React 19 snapshot differences include:
- Component wrapper structure changes
- Attribute ordering differences
- Text node rendering modifications
- Async boundary updates
Use git diff to review snapshot changes before committing.
Last updated: Jul 09, 2026

