Replies: 4 comments
-
Same issue. My const nextJest = require('next/jest');
const createJestConfig = nextJest({
dir: './',
});
const config = {
coverageProvider: 'v8',
testEnvironment: 'jsdom',
};
module.exports = createJestConfig(config); |
Beta Was this translation helpful? Give feedback.
-
Here is my current solution. Add the packages that need to be transpiled in next.config.js: {
...
transpilePackages: [
...
'@t3-oss/env-nextjs',
'@t3-oss/env-core',
],
} Due to Jest being unable to parse untranspiled ESM packages, it is necessary to have webpack transpile them first. In Next.js, this can be accomplished by adding transpilePackages to |
Beta Was this translation helpful? Give feedback.
-
This is still and issue as many of us use |
Beta Was this translation helpful? Give feedback.
-
None of the above worked for me with https://github.com/Blazity/next-enterprise After chasing my tail for longer than I'd like to admit, dancing with babel and every other corner of the ecosystem, good old-fashioned mocking got me through.
I hope that helps someone! |
Beta Was this translation helpful? Give feedback.
-
backdround
When running individual Jest tests, I encounter an error due to the package not being resolved correctly.
the test will show this error:
`
`
});`
Relevant Package Versions:
Project tsconfig settings:
{ "compilerOptions": { "target": "es5", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, "strict": true, "forceConsistentCasingInFileNames": true, "noEmit": true, "esModuleInterop": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", "incremental": true, "baseUrl": "src", "paths": { "@/*": ["*"] } }, "include": ["next-env.d.ts", "next.config.js", "**/*.ts", "**/*.tsx", "src/env.mjs"], "exclude": ["node_modules"] }
Beta Was this translation helpful? Give feedback.
All reactions