Skip to content

Commit fb6cc0e

Browse files
committed
fix(config/jest): import and apply ts-jest preset instead of just setting preset:
Because we're encapsulating the `ts-jest` dependency, there are cases where a package manager won't lift `ts-jest` to the root `node_modules` directory which prevents the preset from being loaded. Importing (`require('ts-jest/presets')`) the preset will always resolve, even when the dependency is nested, e.g: `./node_modules/@hover/javascript/node_modules/ts-jest`
1 parent 281356b commit fb6cc0e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/config/jest.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @typedef {import('@jest/types').Config.InitialOptions} JestConfig */
22

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

56
const ignores = [
67
'/node_modules/',
@@ -59,7 +60,8 @@ const jestConfig = {
5960
}
6061

6162
if (hasAnyDep('ts-jest') || hasFile('tsconfig.json')) {
62-
jestConfig.preset = 'ts-jest/presets/js-with-ts'
63+
Object.assign(jestConfig, preset)
64+
6365
jestConfig.globals['ts-jest'] = {
6466
diagnostics: {
6567
warnOnly: true,

0 commit comments

Comments
 (0)