Skip to content

Commit

Permalink
qa(test): Allow to run the smoke tests aggaint all builded versions
Browse files Browse the repository at this point in the history
  • Loading branch information
armandabric committed May 8, 2018
1 parent 496f20f commit 01eb935
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
12 changes: 8 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 2 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* @flow */

import fs from 'fs';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
Expand All @@ -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({
Expand Down
14 changes: 12 additions & 2 deletions tests/smoke/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
12 changes: 11 additions & 1 deletion tests/smoke/smoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 Exception(`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}"`);

Expand Down

0 comments on commit 01eb935

Please sign in to comment.