Skip to content

Fix Jest config for MSW + axios compatibility#77

Merged
rakeshpetit merged 1 commit into
mainfrom
fix-jest-errors
Apr 17, 2026
Merged

Fix Jest config for MSW + axios compatibility#77
rakeshpetit merged 1 commit into
mainfrom
fix-jest-errors

Conversation

@rakeshpetit
Copy link
Copy Markdown
Contributor

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

@rakeshpetit rakeshpetit merged commit 9292164 into main Apr 17, 2026
2 checks passed
@rakeshpetit rakeshpetit deleted the fix-jest-errors branch April 17, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants