/
create-jest-preset.spec.ts
54 lines (51 loc) · 1.15 KB
/
create-jest-preset.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
42
43
44
45
46
47
48
49
50
51
52
53
54
import { JS_EXT_TO_TREAT_AS_ESM, TS_EXT_TO_TREAT_AS_ESM } from '../constants'
import { createJestPreset } from './create-jest-preset'
describe('create-jest-preset', () => {
const baseExtraOptions = {
testMatch: ['foo'],
moduleFileExtensions: ['bar'],
transform: { foo: 'bar' },
}
test.each([
{
legacy: true,
allowJs: undefined,
extraOptions: undefined,
},
{
legacy: false,
allowJs: false,
extraOptions: undefined,
},
{
legacy: true,
allowJs: true,
extraOptions: undefined,
},
{
legacy: false,
allowJs: true,
extraOptions: {},
},
{
legacy: true,
allowJs: false,
extraOptions: {},
},
{
legacy: false,
allowJs: false,
extraOptions: baseExtraOptions,
},
{
legacy: true,
allowJs: true,
extraOptions: {
...baseExtraOptions,
extensionsToTreatAsEsm: [...JS_EXT_TO_TREAT_AS_ESM, ...TS_EXT_TO_TREAT_AS_ESM],
},
},
])('should return correct preset', (data) => {
expect(createJestPreset(data.legacy, data.allowJs, data.extraOptions)).toMatchSnapshot()
})
})