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
orpheus6678 opened this issue
Mar 13, 2025
· 0 comments
Labels
adaptersChanges related to the core code concerning database adaptersbugSomething isn't workingtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Jest is crashing on reaching prisma adapter code because it uses ES2020 syntax. I know transpilers skip node_modules transpilation by default, and I have not added transformIgnorePatterns on jest.config.js. But I shouldnt have to. I have used next/jest instead which automatically configures jest, and I have transpilePackages: ["@auth/prisma-adapter"] in my next.config.ts (please check out the source). Despite all, jest yields the following on every run. It may be worth noting that next uses swc compiler (and thus @swc/jest) by default instead of babel. I would also like to report this regex execution as an extra.
> [email protected] test E:\convicts
> jest --ci
FAIL src/__tests__/login.test.tsx
● Test suite failed to run
Jest encountered an unexpected token
Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.
By default "node_modules" folder is ignored by transformers.
Here's what you can do:
• If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
• If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation
Details:
E:\convicts\node_modules\.pnpm\@[email protected]_@[email protected][email protected][email protected][email protected][email protected]\node_modules\@auth\prisma-adapter\index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export function PrismaAdapter(prisma) {
^^^^^^
SyntaxError: Unexpected token 'export'
27 | // async create({ args, query }) {
28 | // args.data.username ??= `!${createId()}`
> 29 | // return query(args)
| ^
30 | // },
31 | // },
32 | // },
at Runtime.createScriptFromCode (node_modules/.pnpm/[email protected]/node_modules/jest-runtime/build/index.js:1505:14)
at Object.<anonymous> (src/lib/auth.ts:29:24)
at Object.<anonymous> (src/app/login/page.tsx:13:15)
at Object.<anonymous> (src/__tests__/login.test.tsx:8:54)
(node:15040) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:3248) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
PASS src/__tests__/snapshot.tsx
(node:14976) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
PASS src/__tests__/page.test.tsx
Test Suites: 1 failed, 2 passed, 3 total
Tests: 12 passed, 12 total
Snapshots: 1 passed, 1 total
Time: 8.721 s
Ran all test suites.
ELIFECYCLE Test failed. See above for more details.
How to reproduce
Just run pnpm test in the terminal.
Expected behavior
All tests pass without fail. Or at least, jest should not report this exact error.
The text was updated successfully, but these errors were encountered:
orpheus6678
added
adapters
Changes related to the core code concerning database adapters
bug
Something isn't working
triage
Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
labels
Mar 13, 2025
adaptersChanges related to the core code concerning database adaptersbugSomething isn't workingtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Adapter type
@auth/prisma-adapter
Environment
Reproduction URL
https://github.com/Learnathon-By-Geeky-Solutions/convicts/tree/rf/bug-swc
Describe the issue
Jest is crashing on reaching prisma adapter code because it uses ES2020 syntax. I know transpilers skip node_modules transpilation by default, and I have not added transformIgnorePatterns on jest.config.js. But I shouldnt have to. I have used
next/jest
instead which automatically configures jest, and I havetranspilePackages: ["@auth/prisma-adapter"]
in my next.config.ts (please check out the source). Despite all, jest yields the following on every run. It may be worth noting that next uses swc compiler (and thus @swc/jest) by default instead of babel. I would also like to report this regex execution as an extra.How to reproduce
Just run
pnpm test
in the terminal.Expected behavior
All tests pass without fail. Or at least, jest should not report this exact error.
The text was updated successfully, but these errors were encountered: