From 73683da80b4f68d13291ed4279b23b50c5bd8e23 Mon Sep 17 00:00:00 2001 From: Armand Abric Date: Tue, 8 May 2018 22:32:03 +0200 Subject: [PATCH] qa(test): Allow to run the smoke tests aggaint all builded versions --- .travis.yml | 12 ++++++++---- rollup.config.js | 6 ++---- tests/smoke/run.js | 14 ++++++++++++-- tests/smoke/smoke.js | 12 +++++++++++- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8d50862f1..882bb8b73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,11 @@ script: - yarn run test - yarn run lint - yarn run flow - - yarn run smoke 15.6.2 - - yarn run smoke 16.1.0 - - yarn run smoke default - - yarn run smoke next + - yarn run smoke cjs 15.6.2 + - yarn run smoke esm 15.6.2 + - yarn run smoke cjs 16.1.0 + - yarn run smoke esm 16.1.0 + - yarn run smoke cjs default + - yarn run smoke esm default + - yarn run smoke cjs next + - yarn run smoke esm next diff --git a/rollup.config.js b/rollup.config.js index 1ad046cc5..b3b2e6cb0 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,5 +1,3 @@ -/* @flow */ - import fs from 'fs'; import babel from 'rollup-plugin-babel'; import commonjs from 'rollup-plugin-commonjs'; @@ -19,10 +17,10 @@ const extractPackagePeerDependencies = () => { export default { input: 'src/index.js', output: { - file: 'dist/cjs/bundle.js', + file: 'dist/cjs/index.js', format: 'cjs', + sourcemap: true, }, - sourcemap: true, external: extractPackagePeerDependencies(), plugins: [ babel({ diff --git a/tests/smoke/run.js b/tests/smoke/run.js index 8959459a0..a9a54fb79 100755 --- a/tests/smoke/run.js +++ b/tests/smoke/run.js @@ -3,12 +3,22 @@ const execFileSync = require('child_process').execFileSync; const path = require('path'); -execFileSync(path.join(__dirname, 'prepare.js'), [process.argv[2]], { +const buildType = process.argv[2]; +if (!buildType) { + throw new Error('The build type to test is missing'); +} + +const requestedReactVersion = process.argv[3]; +if (!requestedReactVersion) { + throw new Error('React version to use for the test is missing'); +} + +execFileSync(path.join(__dirname, 'prepare.js'), [requestedReactVersion], { cwd: __dirname, stdio: 'inherit', }); -execFileSync(path.join(__dirname, 'smoke.js'), { +execFileSync(path.join(__dirname, 'smoke.js'), [buildType], { cwd: __dirname, stdio: 'inherit', }); diff --git a/tests/smoke/smoke.js b/tests/smoke/smoke.js index 6cbf55e70..f654efc72 100755 --- a/tests/smoke/smoke.js +++ b/tests/smoke/smoke.js @@ -3,9 +3,19 @@ /* eslint-disable no-console */ /* eslint-disable import/no-extraneous-dependencies */ +const requireReactElementToJsxString = buildType => { + if (buildType === 'esm') { + return require(`./../../dist/esm`).default; + } else if (buildType === 'cjs') { + return require('./../../dist/cjs'); + } + + throw new Error(`Unknown build type: "${buildType}"`); +}; + const expect = require('expect'); const React = require('react'); -const reactElementToJsxString = require('./../../dist/').default; +const reactElementToJsxString = requireReactElementToJsxString(process.argv[2]); console.log(`Tested "react" version: "${React.version}"`);