From e2f1b76d0fd0b574c1b9764f7150a8eb2ff5b17f Mon Sep 17 00:00:00 2001 From: Anton Gilgur Date: Mon, 12 Oct 2020 17:11:55 -0400 Subject: [PATCH] test: add a smoke test that builds _all_ formats - 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 --- test/e2e/tsdx-build-options.test.ts | 53 +++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 test/e2e/tsdx-build-options.test.ts diff --git a/test/e2e/tsdx-build-options.test.ts b/test/e2e/tsdx-build-options.test.ts new file mode 100644 index 000000000..ded530033 --- /dev/null +++ b/test/e2e/tsdx-build-options.test.ts @@ -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); + }); +});