/
ts-jest-compiler.spec.ts
37 lines (31 loc) · 1.26 KB
/
ts-jest-compiler.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
import { createConfigSet } from '../../__helpers__/fakers'
import { TsCompiler } from './ts-compiler'
import { TsJestCompiler } from './ts-jest-compiler'
describe('TsJestCompiler', () => {
TsCompiler.prototype.getResolvedModules = jest.fn()
TsCompiler.prototype.getCompiledOutput = jest.fn()
const runtimeCacheFS = new Map<string, string>()
const fileContent = 'const foo = 1'
const fileName = 'foo.ts'
const compiler = new TsJestCompiler(createConfigSet(), runtimeCacheFS)
describe('getResolvedModules', () => {
test('should call getResolvedModules from compiler instance', () => {
compiler.getResolvedModules(fileContent, fileName, runtimeCacheFS)
expect(TsCompiler.prototype.getResolvedModules).toHaveBeenCalledWith(fileContent, fileName, runtimeCacheFS)
})
})
describe('getCompiledOutput', () => {
test('should call getCompiledOutput from compiler instance', () => {
compiler.getCompiledOutput(fileContent, fileName, {
depGraphs: new Map(),
supportsStaticESM: false,
watchMode: false,
})
expect(TsCompiler.prototype.getCompiledOutput).toHaveBeenCalledWith(fileContent, fileName, {
depGraphs: new Map(),
supportsStaticESM: false,
watchMode: false,
})
})
})
})