Skip to content

Commit

Permalink
test: add a smoke test that builds _all_ formats
Browse files Browse the repository at this point in the history
- there was never a test that built all, meaning tests left out the
  somewhat popular UMD build in particular
  - per my investigation, CJS + UMD, CJS + System, UMD + System started
    bugging out recently due to an upstream bug, but this wasn't known
    proactively because there were no tests for it
    - and I also found that CJS + System actually was bugging out in
      the previous version, TSDX v0.13.3, but I'm guessing no one
      reported it back then as it's an unpopular combination of formats

- this test fails prior to upgrade of rpts2 to v0.27.3 and succeeds
  after the upgrade
  - so this should act as a regression test against this bug as well

- created a new e2e build-options test file for this because
  build-default is meant to have 0 options and test only the defaults
  - had to give it a differentiated "stage" name as it uses the same
    build-default fixture and so breaks during test parallelization
    without that
  - should also move the regeneratorRuntime `--target node` test here
    since that's an option and not a default
  • Loading branch information
agilgur5 committed Oct 12, 2020
1 parent f4eb488 commit 3845d36
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions test/e2e/tsdx-build-options.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import * as shell from 'shelljs';

import * as util from '../utils/fixture';
import { execWithCache } from '../utils/shell';

shell.config.silent = false;

const testDir = 'e2e';
const fixtureName = 'build-default';
// create a second version of build-default's stage for concurrent testing
const stageName = 'stage-build-options';

describe('tsdx build :: options', () => {
beforeAll(() => {
util.teardownStage(stageName);
util.setupStageWithFixture(testDir, stageName, fixtureName);
});

it('should compile all formats', () => {
const output = execWithCache(
'node ../dist/index.js build --format cjs,esm,umd,system'
);

expect(shell.test('-f', 'dist/index.js')).toBeTruthy();
expect(
shell.test('-f', 'dist/build-default.cjs.development.js')
).toBeTruthy();
expect(
shell.test('-f', 'dist/build-default.cjs.production.min.js')
).toBeTruthy();
expect(shell.test('-f', 'dist/build-default.esm.js')).toBeTruthy();
expect(
shell.test('-f', 'dist/build-default.umd.development.js')
).toBeTruthy();
expect(
shell.test('-f', 'dist/build-default.umd.production.min.js')
).toBeTruthy();
expect(
shell.test('-f', 'dist/build-default.system.development.js')
).toBeTruthy();
expect(
shell.test('-f', 'dist/build-default.system.production.min.js')
).toBeTruthy();

expect(shell.test('-f', 'dist/index.d.ts')).toBeTruthy();

expect(output.code).toBe(0);
});

afterAll(() => {
util.teardownStage(stageName);
});
});

0 comments on commit 3845d36

Please sign in to comment.