Skip to content

Commit c94d040

Browse files
committed
feat(config/jest): automatically map tsconfig paths to Jest moduleNameMapper
1 parent 2e60585 commit c94d040

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/config/jest.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const {
99
} = require('@swc-node/register/read-default-tsconfig')
1010

1111
const {ifAnyDep, hasFile, fromRoot, hasDevDep, getDebug} = require('../utils')
12+
const {pathsToModuleNameMapper} = require('../api/test')
1213

1314
const {
1415
testMatch,
@@ -142,6 +143,12 @@ const jestConfig = {
142143
testMatch,
143144
testPathIgnorePatterns: [...ignores, '<rootDir>/dist'],
144145
testLocationInResults: true,
146+
moduleNameMapper: debug.trace(
147+
pathsToModuleNameMapper(
148+
debug.trace(swcConfig.paths, 'moduleNameMapper:paths'),
149+
),
150+
'moduleNameMapper',
151+
),
145152
transform: getTransform(),
146153
coveragePathIgnorePatterns: [
147154
...ignores,

0 commit comments

Comments
 (0)