/
ast-transformers.test.ts
73 lines (53 loc) · 2.27 KB
/
ast-transformers.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import path from 'path'
import execa from 'execa'
import { json as runWithJson } from '../run-jest'
import { runNpmInstall, tsJestBundle } from '../utils'
const AST_TRANSFORMERS_DIR_NAME = 'ast-transformers'
const executeTest = (testDir: string): void => {
test(`successfully runs the tests inside ${testDir} with isolatedModules: false`, () => {
const { json } = runWithJson(testDir)
expect(json.success).toBe(true)
})
test(`successfully runs the tests inside ${testDir} with isolatedModules: true`, () => {
const { json } = runWithJson(testDir, ['-c=jest-isolated.config.js'])
expect(json.success).toBe(true)
})
}
describe('transformer-options', () => {
const TRANSFORM_OPT_DIR_NAME = 'transformer-options'
beforeAll(() => {
runNpmInstall(path.join(__dirname, '..', AST_TRANSFORMERS_DIR_NAME, TRANSFORM_OPT_DIR_NAME))
})
test(`successfully runs the tests inside ${AST_TRANSFORMERS_DIR_NAME}/${TRANSFORM_OPT_DIR_NAME}`, () => {
const { json } = runWithJson(`${AST_TRANSFORMERS_DIR_NAME}/${TRANSFORM_OPT_DIR_NAME}`)
expect(json.success).toBe(true)
})
})
describe('hoist-jest', () => {
const HOIST_JEST_DIR_NAME = 'hoist-jest'
const NON_TS_FACTORY_DIR_NAME = 'non-ts-factory'
const TS_FACTORY_DIR_NAME = 'ts-factory'
describe('non-ts-factory', () => {
const DIR = path.join(__dirname, '..', AST_TRANSFORMERS_DIR_NAME, HOIST_JEST_DIR_NAME, NON_TS_FACTORY_DIR_NAME)
beforeAll(() => {
runNpmInstall(DIR)
execa.sync('npm', ['install', '--no-package-lock', '--no-shrinkwrap', '--no-save', tsJestBundle], {
cwd: DIR,
})
})
executeTest(`${AST_TRANSFORMERS_DIR_NAME}/${HOIST_JEST_DIR_NAME}/${NON_TS_FACTORY_DIR_NAME}`)
})
describe('ts-factory', () => {
beforeAll(() => {
runNpmInstall(path.join(__dirname, '..', AST_TRANSFORMERS_DIR_NAME, HOIST_JEST_DIR_NAME, TS_FACTORY_DIR_NAME))
})
executeTest(`${AST_TRANSFORMERS_DIR_NAME}/${HOIST_JEST_DIR_NAME}/${TS_FACTORY_DIR_NAME}`)
})
})
describe('transformer-in-ts', () => {
const TRANSFORMER_IN_TS_DIR_NAME = `${AST_TRANSFORMERS_DIR_NAME}/transformer-in-ts`
test(`successfully runs the tests inside ${TRANSFORMER_IN_TS_DIR_NAME}`, () => {
const { json } = runWithJson(TRANSFORMER_IN_TS_DIR_NAME)
expect(json.success).toBe(true)
})
})