Skip to content

Commit 01eb935

Browse files
committed
qa(test): Allow to run the smoke tests aggaint all builded versions
1 parent 496f20f commit 01eb935

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

.travis.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ script:
2020
- yarn run test
2121
- yarn run lint
2222
- yarn run flow
23-
- yarn run smoke 15.6.2
24-
- yarn run smoke 16.1.0
25-
- yarn run smoke default
26-
- yarn run smoke next
23+
- yarn run smoke cjs 15.6.2
24+
- yarn run smoke esm 15.6.2
25+
- yarn run smoke cjs 16.1.0
26+
- yarn run smoke esm 16.1.0
27+
- yarn run smoke cjs default
28+
- yarn run smoke esm default
29+
- yarn run smoke cjs next
30+
- yarn run smoke esm next

rollup.config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* @flow */
2-
31
import fs from 'fs';
42
import babel from 'rollup-plugin-babel';
53
import commonjs from 'rollup-plugin-commonjs';
@@ -19,10 +17,10 @@ const extractPackagePeerDependencies = () => {
1917
export default {
2018
input: 'src/index.js',
2119
output: {
22-
file: 'dist/cjs/bundle.js',
20+
file: 'dist/cjs/index.js',
2321
format: 'cjs',
22+
sourcemap: true,
2423
},
25-
sourcemap: true,
2624
external: extractPackagePeerDependencies(),
2725
plugins: [
2826
babel({

tests/smoke/run.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@
33
const execFileSync = require('child_process').execFileSync;
44
const path = require('path');
55

6-
execFileSync(path.join(__dirname, 'prepare.js'), [process.argv[2]], {
6+
const buildType = process.argv[2];
7+
if (!buildType) {
8+
throw new Error('The build type to test is missing');
9+
}
10+
11+
const requestedReactVersion = process.argv[3];
12+
if (!requestedReactVersion) {
13+
throw new Error('React version to use for the test is missing');
14+
}
15+
16+
execFileSync(path.join(__dirname, 'prepare.js'), [requestedReactVersion], {
717
cwd: __dirname,
818
stdio: 'inherit',
919
});
1020

11-
execFileSync(path.join(__dirname, 'smoke.js'), {
21+
execFileSync(path.join(__dirname, 'smoke.js'), [buildType], {
1222
cwd: __dirname,
1323
stdio: 'inherit',
1424
});

tests/smoke/smoke.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@
33
/* eslint-disable no-console */
44
/* eslint-disable import/no-extraneous-dependencies */
55

6+
const requireReactElementToJsxString = buildType => {
7+
if (buildType === 'esm') {
8+
return require(`./../../dist/esm`).default;
9+
} else if (buildType === 'cjs') {
10+
return require('./../../dist/cjs');
11+
}
12+
13+
throw new Exception(`Unknown build type: "${buildType}"`);
14+
};
15+
616
const expect = require('expect');
717
const React = require('react');
8-
const reactElementToJsxString = require('./../../dist/').default;
18+
const reactElementToJsxString = requireReactElementToJsxString(process.argv[2]);
919

1020
console.log(`Tested "react" version: "${React.version}"`);
1121

0 commit comments

Comments
 (0)