-
Notifications
You must be signed in to change notification settings - Fork 504
/
tsdx-build-withConfig.test.ts
64 lines (48 loc) · 1.89 KB
/
tsdx-build-withConfig.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
import * as fs from 'fs-extra';
import * as shell from 'shelljs';
import * as util from '../utils/fixture';
import { execWithCache } from '../utils/shell';
shell.config.silent = false;
const testDir = 'integration';
const fixtureName = 'build-withConfig';
const stageName = `stage-integration-${fixtureName}`;
describe('integration :: tsdx build :: tsdx.config.js', () => {
beforeAll(() => {
util.teardownStage(stageName);
util.setupStageWithFixture(testDir, stageName, fixtureName);
});
it('should create a CSS file in the dist/ directory', () => {
const output = execWithCache('node ../dist/index.js build');
// TODO: this is kind of subpar naming, rollup-plugin-postcss just names it
// the same as the output file, but with the .css extension
expect(shell.test('-f', 'dist/build-withconfig.cjs.development.css'));
expect(output.code).toBe(0);
});
it('should autoprefix and minify the CSS file', async () => {
const output = execWithCache('node ../dist/index.js build');
const cssText = await fs.readFile(
'./dist/build-withconfig.cjs.development.css'
);
// autoprefixed and minifed output
expect(
cssText.includes('.test::-webkit-input-placeholder{color:"blue"}')
).toBeTruthy();
expect(output.code).toBe(0);
});
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-withconfig.cjs.development.js')
).toBeTruthy();
expect(
shell.test('-f', 'dist/build-withconfig.cjs.production.min.js')
).toBeTruthy();
expect(shell.test('-f', 'dist/build-withconfig.esm.js')).toBeTruthy();
expect(shell.test('-f', 'dist/index.d.ts')).toBeTruthy();
expect(output.code).toBe(0);
});
afterAll(() => {
util.teardownStage(stageName);
});
});