-
Notifications
You must be signed in to change notification settings - Fork 504
/
tsdx-build-withBabel.test.ts
76 lines (59 loc) · 2.38 KB
/
tsdx-build-withBabel.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
74
75
76
import * as shell from 'shelljs';
import * as util from '../utils/fixture';
import { execWithCache, grep } from '../utils/shell';
shell.config.silent = false;
const testDir = 'integration';
const fixtureName = 'build-withBabel';
const stageName = `stage-integration-${fixtureName}`;
describe('integration :: tsdx build :: .babelrc.js', () => {
beforeAll(() => {
util.teardownStage(stageName);
util.setupStageWithFixture(testDir, stageName, fixtureName);
});
it('should convert styled-components template tags', () => {
const output = execWithCache('node ../dist/index.js build');
expect(output.code).toBe(0);
// from styled.h1` to styled.h1(
const matched = grep(/styled.h1\(/, ['dist/build-withbabel.*.js']);
expect(matched).toBeTruthy();
});
// TODO: make this test work by allowing customization of plugin order
it.skip('should remove comments in the CSS', () => {
const output = execWithCache('node ../dist/index.js build');
expect(output.code).toBe(0);
// the "should be removed" comment shouldn't be there (gets error code)
const matched = grep(/should be removed/, ['dist/build-withbabel.*.js']);
expect(matched).toBeTruthy();
});
it('should add an import of regeneratorRuntime', () => {
const output = execWithCache('node ../dist/index.js build');
expect(output.code).toBe(0);
const matched = grep(/@babel\/runtime\/regenerator/, [
'dist/build-withbabel.*.js',
]);
expect(matched).toBeTruthy();
});
it('should merge and apply presets', () => {
const output = execWithCache('node ../dist/index.js build');
expect(output.code).toBe(0);
// ensures replace-identifiers was used
const matched = grep(/replacedSum/, ['dist/build-withbabel.*.js']);
expect(matched).toBeTruthy();
});
it('should compile files into a dist directory', () => {
const output = execWithCache('node ../dist/index.js build');
expect(shell.test('-f', 'dist/index.js')).toBeTruthy();
expect(
shell.test('-f', 'dist/build-withbabel.cjs.development.js')
).toBeTruthy();
expect(
shell.test('-f', 'dist/build-withbabel.cjs.production.min.js')
).toBeTruthy();
expect(shell.test('-f', 'dist/build-withbabel.esm.js')).toBeTruthy();
expect(shell.test('-f', 'dist/index.d.ts')).toBeTruthy();
expect(output.code).toBe(0);
});
afterAll(() => {
util.teardownStage(stageName);
});
});