Skip to content

Commit 438ed61

Browse files
authored
fix: use modulePaths to improve Jest 27 imports (#220)
1 parent 32f3cfb commit 438ed61

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/config/jest.config.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const path = require('path')
2-
const {ifAnyDep, hasFile, hasPkgProp, fromRoot} = require('../utils')
2+
const {ifAnyDep, hasFile, hasPkgProp} = require('../utils')
33

44
const here = p => path.join(__dirname, p)
55

@@ -15,20 +15,15 @@ const ignores = [
1515
]
1616

1717
const jestConfig = {
18-
roots: [fromRoot('src')],
18+
roots: ['<rootDir>/src'],
1919
testEnvironment: ifAnyDep(
2020
['webpack', 'rollup', 'react', 'preact'],
2121
'jsdom',
2222
'node',
2323
),
2424
testURL: 'http://localhost',
2525
moduleFileExtensions: ['js', 'jsx', 'json', 'ts', 'tsx'],
26-
moduleDirectories: [
27-
'node_modules',
28-
fromRoot('src'),
29-
'shared',
30-
fromRoot('tests'),
31-
],
26+
modulePaths: ['<rootDir>/src', 'shared', '<rootDir>/tests'],
3227
collectCoverageFrom: ['src/**/*.+(js|jsx|ts|tsx)'],
3328
testMatch: ['**/__tests__/**/*.+(js|jsx|ts|tsx)'],
3429
testPathIgnorePatterns: [...ignores],
@@ -59,7 +54,7 @@ const setupFiles = [
5954
]
6055
for (const setupFile of setupFiles) {
6156
if (hasFile(setupFile)) {
62-
jestConfig.setupFilesAfterEnv = [fromRoot(setupFile)]
57+
jestConfig.setupFilesAfterEnv = `<rootDir>/${setupFile}`
6358
}
6459
}
6560

0 commit comments

Comments
 (0)