File tree 2 files changed +9
-10
lines changed
2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change 2
2
"private" : true ,
3
3
"scripts" : {
4
4
"dev" : " next dev" ,
5
- "lint" : " next lint" ,
6
5
"build" : " next build" ,
7
6
"start" : " next start" ,
8
7
"test" : " jest --watch" ,
18
17
"@testing-library/react" : " 12.1.2" ,
19
18
"@testing-library/user-event" : " 13.5.0" ,
20
19
"@types/react" : " 17.0.38" ,
21
- "babel-jest" : " 27.4.5" ,
22
- "eslint" : " 8.5.0" ,
23
- "eslint-config-next" : " latest" ,
24
- "eslint-plugin-testing-library" : " 5.0.1" ,
25
20
"jest" : " 27.4.5" ,
26
21
"typescript" : " 4.5.4"
27
22
}
Original file line number Diff line number Diff line change @@ -76,10 +76,6 @@ export default function nextJest(options: { dir?: string } = {}) {
76
76
...resolvedJestConfig ,
77
77
78
78
moduleNameMapper : {
79
- // Custom config will be able to override the default mappings
80
- // moduleNameMapper is matched top to bottom hence why this has to be before Next.js internal rules
81
- ...( resolvedJestConfig . moduleNameMapper || { } ) ,
82
-
83
79
// Handle CSS imports (with CSS modules)
84
80
// https://jestjs.io/docs/webpack#mocking-css-modules
85
81
'^.+\\.module\\.(css|sass|scss)$' :
@@ -89,9 +85,17 @@ export default function nextJest(options: { dir?: string } = {}) {
89
85
'^.+\\.(css|sass|scss)$' : require . resolve ( './__mocks__/styleMock.js' ) ,
90
86
91
87
// Handle image imports
92
- '^.+\\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg )$' : require . resolve (
88
+ '^.+\\.(png|jpg|jpeg|gif|webp|avif|ico|bmp)$' : require . resolve (
93
89
`./__mocks__/fileMock.js`
94
90
) ,
91
+
92
+ // Keep .svg to it's own rule to make overriding easy
93
+ '^.+\\.(svg)$' : require . resolve ( `./__mocks__/fileMock.js` ) ,
94
+
95
+ // custom config comes last to ensure the above rules are matched,
96
+ // fixes the case where @pages /(.*) -> src/pages/$! doesn't break
97
+ // CSS/image mocks
98
+ ...( resolvedJestConfig . moduleNameMapper || { } ) ,
95
99
} ,
96
100
testPathIgnorePatterns : [
97
101
// Don't look for tests in node_modules
You can’t perform that action at this time.
0 commit comments