-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.config.js
More file actions
110 lines (107 loc) · 4.41 KB
/
jest.config.js
File metadata and controls
110 lines (107 loc) · 4.41 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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 customJestConfig = {
// Add more setup options before each test is run
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
moduleDirectories: ["node_modules", "__tests__/test-utils", "<rootDir>/"],
moduleNameMapper: {
// Handle module aliases (this will be automatically configured for you soon)
// "^components$": "<rootDir>/components",
// "^page-components$": "<rootDir>/page-components",
// "^tf-components$": "<rootDir>/tf-components",
// "^layout-components$": "<rootDir>/layout-components",
// "^pages$": "<rootDir>/pages",
// "^constants$": "<rootDir>/constants",
// "^contexts$": "<rootDir>/contexts",
// "^hooks$": "<rootDir>/hooks",
// "^helpers$": "<rootDir>/helpers",
// "^utils$": "<rootDir>/utils",
// "^libs$": "<rootDir>/libs",
"^components/(.*)$": "<rootDir>/components/$1",
"^page-components/(.*)$": "<rootDir>/page-components/$1",
"^tf-components/(.*)$": "<rootDir>/tf-components/$1",
"^layout-components/(.*)$": "<rootDir>/layout-components/$1",
"^pages/(.*)$": "<rootDir>/pages/$1",
// "^features/(.*)$": "<rootDir>/features/$1",
"^constants/(.*)$": "<rootDir>/constants/$1",
"^contexts/(.*)$": "<rootDir>/contexts/$1",
"^hooks/(.*)$": "<rootDir>/hooks/$1",
"^helpers/(.*)$": "<rootDir>/helpers/$1", // Add alias for helpers directory
"^public/(.*)$": "<rootDir>/public/$1",
"^styles/(.*)$": "<rootDir>/styles/$1",
"^utils/(.*)$": "<rootDir>/utils/$1",
"^tests/(.*)$": "<rootDir>/__tests__/$1",
"^libs/(.*)$": "<rootDir>/libs/$1",
// ESM heavy deps stubbed for tests not needing real implementations (rules: tests, isolation)
"^jose$": "<rootDir>/__tests__/test-utils/esmStub.js",
"^jose/(.*)$": "<rootDir>/__tests__/test-utils/esmStub.js",
"^@copilotkit/(.*)$": "<rootDir>/__tests__/test-utils/esmStub.js",
"^@segment/(.*)$": "<rootDir>/__tests__/test-utils/esmStub.js",
},
testEnvironment: "jsdom",
fakeTimers: { enableGlobally: true },
// Allow transformation of selected ESM modules; others remain ignored for performance
transform: {
"^.+\\.(js|jsx|ts|tsx)$": ["babel-jest", { presets: ["next/babel"] }],
},
transformIgnorePatterns: [
"node_modules/(?!(remark-gfm|react-markdown|vfile|unist|unified|bail|is-plain-obj|trough|remark|micromark|markdown-table|decode-named-character-reference|character-entities|property-information|hast|space-separated-tokens|comma-separated-tokens|mdast|mdast-util-to-hast|remark-rehype|trim-lines|rehype|html-void-elements|ccount|escape-string-regexp|strip-markdown|react-is|estree-util|format|is-|mdast-util-|unist-util-|zwitch|hastscript|web-namespaces|jose|@copilotkit|@segment)/)",
],
collectCoverage: true,
coverageProvider: "v8",
coverageThreshold: {
global: {
// branches: 80,
// functions: 80,
lines: 60,
// statements: -10,
},
},
coverageReporters: [
"json",
[
"text",
{
skipFull: true, // Set to false to see full list of components being tested
},
],
"text-summary",
],
collectCoverageFrom: [
// "<rootDir>/pages/**/{!(_app),}.{js,ts,jsx,tsx}",
"<rootDir>/components/**/{!(index),}.{js,ts,jsx,tsx}",
// "<rootDir>/page-components/**/{!(index),}.{js,ts,jsx,tsx}",
"<rootDir>/tf-components/**/{!(index),}.{js,ts,jsx,tsx}",
// "<rootDir>/layout-components/**/{!(index),}.{js,ts,jsx,tsx}",
"<rootDir>/contexts/**/{!(index),}.{js,ts,jsx,tsx}",
"<rootDir>/hooks/**/{!(index),}.{js,ts,jsx,tsx}",
"<rootDir>/utils/**/{!(index),}.{js,ts,jsx,tsx}",
"<rootDir>/helpers/**/{!(index),}.{js,ts,jsx,tsx}",
// "<rootDir>/features/**/{!(index),}.{js,ts,jsx,tsx}",
"!<rootDir>/**/*.stories.{js,ts,jsx,tsx,mdx}",
"!<rootDir>/**/*.mocks.{js,ts}",
"!<rootDir>/**/*.mock.{js,ts}",
],
coveragePathIgnorePatterns: [
"<rootDir>/__tests__/test-utils/",
".stories.{js,ts,jsx,tsx,mdx}",
".mocks.{js,ts}",
".mock.{js,ts}",
],
testPathIgnorePatterns: [
"<rootDir>/__tests__/test-utils/",
"<rootDir>/__tests__/fixtures/",
".stories.{js,ts,jsx,tsx,mdx}",
".mocks.{js,ts}",
".mock.{js,ts}",
],
verbose: true,
};
// createJestConfig is exported as a default export
export default createJestConfig(customJestConfig);