Skip to content

Commit

Permalink
fix: use modulePaths to improve Jest 27 imports (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickserv authored Sep 15, 2021
1 parent 32f3cfb commit 438ed61
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/config/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path')
const {ifAnyDep, hasFile, hasPkgProp, fromRoot} = require('../utils')
const {ifAnyDep, hasFile, hasPkgProp} = require('../utils')

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

Expand All @@ -15,20 +15,15 @@ const ignores = [
]

const jestConfig = {
roots: [fromRoot('src')],
roots: ['<rootDir>/src'],
testEnvironment: ifAnyDep(
['webpack', 'rollup', 'react', 'preact'],
'jsdom',
'node',
),
testURL: 'http://localhost',
moduleFileExtensions: ['js', 'jsx', 'json', 'ts', 'tsx'],
moduleDirectories: [
'node_modules',
fromRoot('src'),
'shared',
fromRoot('tests'),
],
modulePaths: ['<rootDir>/src', 'shared', '<rootDir>/tests'],
collectCoverageFrom: ['src/**/*.+(js|jsx|ts|tsx)'],
testMatch: ['**/__tests__/**/*.+(js|jsx|ts|tsx)'],
testPathIgnorePatterns: [...ignores],
Expand Down Expand Up @@ -59,7 +54,7 @@ const setupFiles = [
]
for (const setupFile of setupFiles) {
if (hasFile(setupFile)) {
jestConfig.setupFilesAfterEnv = [fromRoot(setupFile)]
jestConfig.setupFilesAfterEnv = `<rootDir>/${setupFile}`
}
}

Expand Down

0 comments on commit 438ed61

Please sign in to comment.