/
path-mapping.test.ts
40 lines (36 loc) · 958 Bytes
/
path-mapping.test.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
import { configureTestCase } from '../__helpers__/test-case'
import { allValidPackageSets } from '../__helpers__/templates'
function executeTest(rootDirs?: string[]) {
const testCase = configureTestCase('path-mapping', {
tsJestConfig: {
tsConfig: {
rootDirs,
baseUrl: '.',
paths: {
'@share/*': ['share/*']
}
},
astTransformers: {
before: [
'ts-jest/dist/transformers/path-mapping'
],
},
},
writeIo: true,
})
testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => {
it(testLabel, () => {
const result = runTest()
expect(result.status).toBe(0)
expect(result).toMatchSnapshot(rootDirs ? 'with rootDirs' : 'without rootDirs')
})
})
}
describe('Path mapping', () => {
describe('without rootDirs', () => {
executeTest()
})
describe('with rootDirs', () => {
executeTest(['./'])
})
})