-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems with package import in version 0.9.1, How can I make Jest work successfully? #242
Comments
Same issue. My const nextJest = require('next/jest');
const createJestConfig = nextJest({
dir: './',
});
const config = {
coverageProvider: 'v8',
testEnvironment: 'jsdom',
};
module.exports = createJestConfig(config); |
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 |
This is still and issue as many of us use |
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! |
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"] }
The text was updated successfully, but these errors were encountered: