Skip to content

Commit 5fdb24e

Browse files
committed
fix(config/jest): ensure ts-jest transform is resolved even when nested
1 parent d6ce63f commit 5fdb24e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/config/jest.config.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/** @typedef {import('@jest/types').Config.InitialOptions} JestConfig */
22

3+
const {jsWithTs: preset} = require('ts-jest/presets')
4+
35
const {ifAnyDep, hasAnyDep, hasFile, fromRoot} = require('../utils')
46

57
const ignores = [
@@ -59,7 +61,15 @@ const jestConfig = {
5961
}
6062

6163
if (hasAnyDep('ts-jest') || hasFile('tsconfig.json')) {
62-
jestConfig.preset = 'ts-jest/presets/js-with-ts'
64+
jestConfig.transform = Object.fromEntries(
65+
// Ensure we can resolve the preset even when
66+
// it's in a nested `node_modules` installation
67+
Object.entries(preset.transform).map(([key, value]) => [
68+
key,
69+
require.resolve(value),
70+
]),
71+
)
72+
6373
jestConfig.globals['ts-jest'] = {
6474
diagnostics: {
6575
warnOnly: true,

0 commit comments

Comments
 (0)