-
Notifications
You must be signed in to change notification settings - Fork 450
/
disable-sourcemap-support.spec.ts
43 lines (33 loc) · 1.27 KB
/
disable-sourcemap-support.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
import runJest from '../__helpers__/runJest';
import { process } from '../../src/preprocessor';
import * as utils from '../../src/utils';
describe('sourcemap-support', () => {
function runProcess(jestConfig = {}) {
return process('input_code', 'fake_file.ts', jestConfig, {
instrument: false,
});
}
it('should be used by default', () => {
const spy = jest.spyOn(utils, 'injectSourcemapHook');
runProcess();
expect(spy).toHaveBeenCalled();
spy.mockReset();
spy.mockRestore();
});
it(`should not be used when the disableSourceMapSupport flag is set to true`, async () => {
const spy = jest.spyOn(utils, 'injectSourcemapHook');
runProcess({ globals: { 'ts-jest': { disableSourceMapSupport: true } } });
expect(spy).not.toHaveBeenCalled();
spy.mockReset();
spy.mockRestore();
});
it(`should be used when the disableSourceMapSupport flag is set to anything other than true`, async () => {
const spy = jest.spyOn(utils, 'injectSourcemapHook');
runProcess({ globals: { 'ts-jest': { disableSourceMapSupport: 'true' } } });
expect(spy).toHaveBeenCalled();
runProcess({ globals: { 'ts-jest': { disableSourceMapSupport: 1 } } });
expect(spy).toHaveBeenCalled();
spy.mockReset();
spy.mockRestore();
});
});