-
Notifications
You must be signed in to change notification settings - Fork 504
/
tsdx-build-withTsconfig.test.js
69 lines (54 loc) · 2.25 KB
/
tsdx-build-withTsconfig.test.js
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
const shell = require('shelljs');
const util = require('../utils/fixture');
const { execWithCache } = require('../utils/shell');
shell.config.silent = false;
const testDir = 'e2e';
const fixtureName = 'build-withTsconfig';
const stageName = `stage-${fixtureName}`;
describe('tsdx build :: build with custom tsconfig.json options', () => {
beforeAll(() => {
util.teardownStage(stageName);
util.setupStageWithFixture(testDir, stageName, fixtureName);
});
it('should use the declarationDir when set', () => {
const output = execWithCache('node ../dist/index.js build');
expect(shell.test('-f', 'dist/index.js')).toBeTruthy();
expect(
shell.test('-f', 'dist/build-withtsconfig.cjs.development.js')
).toBeTruthy();
expect(
shell.test('-f', 'dist/build-withtsconfig.cjs.production.min.js')
).toBeTruthy();
expect(shell.test('-f', 'dist/build-withtsconfig.esm.js')).toBeTruthy();
expect(shell.test('-f', 'dist/index.d.ts')).toBeFalsy();
expect(shell.test('-f', 'typings/index.d.ts')).toBeTruthy();
expect(shell.test('-f', 'typings/index.d.ts.map')).toBeTruthy();
expect(output.code).toBe(0);
});
it('should set __esModule according to esModuleInterop', () => {
const output = execWithCache('node ../dist/index.js build');
const lib = require(`../../${stageName}/dist/build-withtsconfig.cjs.production.min.js`);
// if esModuleInterop: false, no __esModule is added, therefore undefined
expect(lib.__esModule).toBe(undefined);
expect(output.code).toBe(0);
});
it('should read custom --tsconfig path', () => {
const output = execWithCache(
'node ../dist/index.js build --format cjs --tsconfig ./src/tsconfig.json'
);
expect(shell.test('-f', 'dist/index.js')).toBeTruthy();
expect(
shell.test('-f', 'dist/build-withtsconfig.cjs.development.js')
).toBeTruthy();
expect(
shell.test('-f', 'dist/build-withtsconfig.cjs.production.min.js')
).toBeTruthy();
expect(shell.test('-f', 'dist/index.d.ts')).toBeFalsy();
expect(shell.test('-f', 'typingsCustom/index.d.ts')).toBeTruthy();
expect(shell.test('-f', 'typingsCustom/index.d.ts.map')).toBeTruthy();
expect(output.code).toBe(0);
});
afterAll(() => {
util.teardownStage(stageName);
});
});