/
ts-jest-presets.spec.ts
41 lines (40 loc) · 1.09 KB
/
ts-jest-presets.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// preset and utils should work all the time
import * as presets from 'ts-jest/presets'
import { JS_EXT_TO_TREAT_AS_ESM, TS_EXT_TO_TREAT_AS_ESM } from 'ts-jest/dist/constants'
test('presets', () => {
expect(presets.defaults).toEqual({
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
})
expect(presets.defaultsESM).toEqual({
extensionsToTreatAsEsm: [...TS_EXT_TO_TREAT_AS_ESM],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
})
expect(presets.jsWithTs).toEqual({
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
},
})
expect(presets.jsWithTsESM).toEqual({
extensionsToTreatAsEsm: [...JS_EXT_TO_TREAT_AS_ESM, ...TS_EXT_TO_TREAT_AS_ESM],
transform: {
'^.+\\.m?[tj]sx?$': 'ts-jest',
},
})
expect(presets.jsWithBabel).toEqual({
transform: {
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.jsx?$': 'babel-jest',
},
})
expect(presets.jsWithBabelESM).toEqual({
extensionsToTreatAsEsm: [...JS_EXT_TO_TREAT_AS_ESM, ...TS_EXT_TO_TREAT_AS_ESM],
transform: {
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.m?[j]sx?$': 'babel-jest',
},
})
})