Skip to content

Commit 15e2ba7

Browse files
committed
Fix jest.config.ts
1 parent 627bec0 commit 15e2ba7

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

examples/publish-ci/react-native/jest.config.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,26 @@ import type { Config } from "jest"
22

33
const config: Config = {
44
preset: "react-native",
5-
testEnvironment: "node",
5+
verbose: true,
6+
/**
7+
* Without this we will get the following error:
8+
* `SyntaxError: Cannot use import statement outside a module`
9+
*/
10+
transformIgnorePatterns: [
11+
"node_modules/(?!((jest-)?react-native|...|react-redux))",
12+
],
13+
/**
14+
* React Native's `jest` preset includes a
15+
* [polyfill for `window`](https://github.com/facebook/react-native/blob/acb634bc9662c1103bc7c8ca83cfdc62516d0060/packages/react-native/jest/setup.js#L61-L66).
16+
* This polyfill causes React-Redux to use `useEffect`
17+
* instead of `useLayoutEffect` for the `useIsomorphicLayoutEffect` hook.
18+
* As a result, nested component updates may not be properly batched
19+
* when using the `connect` API, leading to potential issues.
20+
*/
21+
globals: {
22+
window: undefined,
23+
navigator: { product: "ReactNative" },
24+
},
625
setupFilesAfterEnv: ["<rootDir>/jest-setup.ts"],
726
fakeTimers: { enableGlobally: true },
827
}

0 commit comments

Comments
 (0)