Commit 9292164
authored
Fix Jest config for MSW + axios compatibility (#77)
## Description
Jest tests were failing with the error below on freshly created Expo app
using the CLI.
```
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { LensList } from "./lens-list.mjs";
^^^^^^
SyntaxError: Cannot use import statement outside a module
> 1 | import { setupServer } from 'msw/node';
| ^
2 |
3 | /**
4 | * MSW server for mocking network requests
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
at Object.<anonymous> (node_modules/msw/src/core/experimental/define-network.ts:2:47)
at Object.<anonymous> (node_modules/msw/src/node/setup-server.ts:9:8)
at Object.require (src/test/server.ts:1:1)
at Object.require (jest.setup.js:4:1)
```
Jest fixes were made to the Expo app built from the boilerplate Belt
template and ported to the CLI as well so that tests for new apps don't
break.
## Related links
- https://mswjs.io/docs/integrations/react-native/#prerequisites
- mswjs/msw#2698
- mswjs/msw#1701 parent c39e3c4 commit 9292164
2 files changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
0 commit comments