You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a vanilla React Native project, based on https://reactnative.dev/docs/environment-setup (run npx react-native@latest init AwesomeProjectSwc), then following the @swc/jest instructions for using swc with jest ( https://swc.rs/docs/usage/jest ), running yarn test will then fail with this unexpected error:
$ yarn test
yarn run v1.22.19
$ jest
FAIL __tests__/App.test.tsx
● Test suite failed to run
× Expected ';', '}' or <eof>
╭─[~/AwesomeProjectSwc/node_modules/@react-native/js-polyfills/error-guard.js:11:1]
11 │
12 │ let _inGuard = 0;
13 │
14 │ type ErrorHandler = (error: mixed, isFatal: boolean) => void;
· ──┬─ ────────────
· ╰── This is the expression part of an expression statement
15 │ type Fn<Args, Return> = (...Args) => Return;
16 │
17 │ /**
╰────
Caused by:
Syntax Error
at Compiler.transformSync (node_modules/@swc/core/index.js:244:29)
at transformSync (node_modules/@swc/core/index.js:351:21)
at Object.process (node_modules/@swc/jest/index.js:73:45)
at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:545:31)
at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:674:40)
at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:726:19)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.074 s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Input code
No response
Config
No response
Playground link (or link to the minimal reproduction)
Looking for jest and this file name, which seems to be implemented in flow, I also found react-native-community/upgrade-support#152 - but adding the suggested transformIgnorePatterns didn't help either.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Describe the bug
When creating a vanilla React Native project, based on https://reactnative.dev/docs/environment-setup (run npx react-native@latest init AwesomeProjectSwc), then following the @swc/jest instructions for using swc with jest ( https://swc.rs/docs/usage/jest ), running yarn test will then fail with this unexpected error:
Input code
No response
Config
No response
Playground link (or link to the minimal reproduction)
https://github.com/jzaefferer/swc-jest-react-native-repro
SWC Info output
$ npx -y swc-info@latest
Expected behavior
Jest tests should run
Actual behavior
No response
Version
"@swc/core": "^1.3.95", "@swc/jest": "^0.2.29",
Additional context
swc-project/jest#40 (comment) looks somewhat related, but the suggested fix didn't work for me.
Looking for jest and this file name, which seems to be implemented in flow, I also found react-native-community/upgrade-support#152 - but adding the suggested transformIgnorePatterns didn't help either.
The repro repo uses the
react-native
Jest preset, which already includestransformIgnorePatterns
: https://github.com/facebook/react-native/blob/0.72-stable/packages/react-native/jest-preset.jshttps://github.com/swc-project/jest has more information than https://swc.rs/docs/usage/jest - might be worth linking to the GitHub readme. Though I didn't found a solution there either.
The text was updated successfully, but these errors were encountered: