Repository navigation
Expand file tree
/
Copy pathjest.config.mjs
More file actions
38 lines (35 loc) · 1.63 KB
/
Copy pathjest.config.mjs
File metadata and controls
38 lines (35 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import nextJest from 'next/jest.js';
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './',
});
// Add any custom config to be passed to Jest
/** @type {import('jest').Config} */
const config = {
// Add more setup options before each test is run
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
testEnvironment: 'jsdom',
testEnvironmentOptions: {
customExportConditions: [''],
},
// preset: 'ts-jest', // Removed: next/jest handles transpilation
moduleNameMapper: {
// Next/SWC may rewrite tsconfig aliases to long relative paths in tests.
'^(?:\\.\\./)+\\.\\/src\\/(.*)$': '<rootDir>/src/$1',
// Handle module aliases (this will be automatically configured for you soon)
'^@/components/(.*)$': '<rootDir>/src/components/$1',
'^@/lib/(.*)$': '<rootDir>/src/lib/$1',
'^@/app/(.*)$': '<rootDir>/src/app/$1',
// Ensure @/generated/prisma is mapped if it's used directly elsewhere, though mocks target @/lib/prisma
'^@/generated/prisma$': '<rootDir>/src/generated/prisma',
},
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'], // if you have a setup file
testPathIgnorePatterns: ['<rootDir>/tests/e2e/'],
// Adjusted transformIgnorePatterns for ESM modules
transformIgnorePatterns: [
'/node_modules/(?!(@auth/prisma-adapter|next-auth|@prisma/client|@vercel/analytics))/', // Transform these specific ESM packages
'^.+\\.module\\.(css|sass|scss)$'
],
};
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
export default createJestConfig(config);