File size: 1,912 Bytes
1e92f2d | 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 | 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-options';
const stageName = `stage-integration-${fixtureName}`;
describe('integration :: tsdx build :: options', () => {
beforeAll(() => {
util.teardownStage(stageName);
util.setupStageWithFixture(testDir, stageName, fixtureName);
});
it('should create errors/ dir with --extractErrors', () => {
const output = execWithCache('node ../dist/index.js build --legacy --extractErrors');
expect(shell.test('-f', 'errors/ErrorDev.js')).toBeTruthy();
expect(shell.test('-f', 'errors/ErrorProd.js')).toBeTruthy();
expect(shell.test('-f', 'errors/codes.json')).toBeTruthy();
expect(output.code).toBe(0);
});
it('should have correct errors/codes.json', () => {
const output = execWithCache('node ../dist/index.js build --legacy --extractErrors');
const errors = require(`../../${stageName}/errors/codes.json`);
expect(errors['0']).toBe('error occurred! o no');
// TODO: warning is actually not extracted, only invariant
// expect(errors['1']).toBe('warning - water is wet');
expect(output.code).toBe(0);
});
it('should compile files into a dist directory', () => {
const output = execWithCache('node ../dist/index.js build --legacy --extractErrors');
expect(shell.test('-f', 'dist/index.cjs')).toBeTruthy();
expect(shell.test('-f', 'dist/build-options.development.cjs')).toBeTruthy();
expect(
shell.test('-f', 'dist/build-options.production.min.cjs')
).toBeTruthy();
expect(shell.test('-f', 'dist/build-options.min.mjs')).toBeTruthy();
expect(shell.test('-f', 'dist/index.d.ts')).toBeTruthy();
expect(output.code).toBe(0);
});
afterAll(() => {
util.teardownStage(stageName);
});
});
|