-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathjest.config.mjs
More file actions
44 lines (41 loc) · 2.01 KB
/
jest.config.mjs
File metadata and controls
44 lines (41 loc) · 2.01 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
39
40
41
42
43
44
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
dir: './',
});
// Add any custom config to be passed to Jest
const customJestConfig = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.mjs'],
testEnvironment: 'jsdom',
moduleNameMapper: {
'^~/(.*)$': '<rootDir>/app/$1',
},
testMatch: ['**/__tests__/**/*.(ts|tsx|js)', '**/*.(test|spec).(ts|tsx|js)'],
testPathIgnorePatterns: ['<rootDir>/tests/e2e/'],
collectCoverageFrom: ['app/**/*.{ts,tsx}', '!app/**/*.d.ts', '!app/**/*.spec.{ts,tsx}', '!app/**/*.test.{ts,tsx}'],
transform: {
'^.+\\.(ts|tsx)$': [
'ts-jest',
{
tsconfig: 'tsconfig.json',
useESM: true,
},
],
},
transformIgnorePatterns: [
'node_modules/(?!(react-markdown|chalk|@ai-sdk|eventsource-parser|react-markdown|remark-.*|rehype-.*|unified|unist-.*|mdast-.*|micromark|decode-named-character-reference|character-entities|property-information|hast-util-.*|space-separated-tokens|comma-separated-tokens|remark-parse|remark-stringify|remark-rehype|rehype-stringify|rehype-parse|rehype-raw|rehype-sanitize|rehype-remark|unist-util-.*|mdast-util-.*|micromark-.*|decode-named-character-reference|character-entities|property-information|hast-util-.*|space-separated-tokens|comma-separated-tokens|react-markdown|remark-gfm|rehype-raw|rehype-sanitize|unified|unist-util-visit|mdast-util-.*|micromark-.*|decode-named-character-reference|character-entities|property-information|hast-util-.*|space-separated-tokens|comma-separated-tokens)/)',
],
extensionsToTreatAsEsm: ['.ts', '.tsx'],
globals: {
'ts-jest': {
useESM: true,
},
},
testEnvironmentOptions: {
customExportConditions: [''],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
preset: 'ts-jest/presets/default-esm',
};
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
export default createJestConfig(customJestConfig);