Skip to content

Commit dc86084

Browse files
committed
Revert smoke test to JS
1 parent c78cedc commit dc86084

File tree

3 files changed

+45
-32
lines changed

3 files changed

+45
-32
lines changed

tests/smoke/prepare.ts renamed to tests/smoke/prepare.js

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
/* eslint-disable no-console */
44

55
const fs = require('fs');
6-
76
const path = require('path');
8-
97
const execSync = require('child_process').execSync;
108

119
const requestedReactVersion = process.argv[2];
12-
1310
if (!requestedReactVersion) {
1411
throw new Error("React version is missing: '$ ./prepare 16.0.0'");
1512
}
@@ -21,41 +18,53 @@ const deleteExistingDependencies = () => () => {
2118
if (fs.existsSync(nodeModulesPath)) {
2219
execSync(`rm -r "${nodeModulesPath}"`, {
2320
cwd: __dirname,
24-
stdio: 'inherit'
21+
stdio: 'inherit',
2522
});
2623
}
2724

2825
if (fs.existsSync(packageJsonPath)) {
2926
execSync(`rm "${packageJsonPath}"`, {
3027
cwd: __dirname,
31-
stdio: 'inherit'
28+
stdio: 'inherit',
3229
});
3330
}
3431
};
3532

36-
const preparePackageJson = reactVersion => () => {
33+
const preparePackageJson = (reactVersion) => () => {
3734
const packageJson = {
3835
name: 'smoke',
3936
version: '0.0.1',
4037
main: 'index.js',
4138
license: 'MIT',
4239
private: true,
4340
dependencies: {
44-
react: reactVersion
45-
}
41+
react: reactVersion,
42+
},
4643
};
47-
fs.writeFileSync(path.join(__dirname, 'package.json'), JSON.stringify(packageJson, null, 2));
44+
45+
fs.writeFileSync(
46+
path.join(__dirname, 'package.json'),
47+
JSON.stringify(packageJson, null, 2)
48+
);
4849
};
4950

50-
const installDependencies = () => () => new Promise(() => {
51-
if (!fs.existsSync(packageJsonPath)) {
52-
return;
53-
}
51+
const installDependencies = () => () =>
52+
new Promise(() => {
53+
if (!fs.existsSync(packageJsonPath)) {
54+
return;
55+
}
5456

55-
execSync('yarn install --no-lockfile', {
56-
cwd: __dirname,
57-
stdio: 'inherit'
57+
execSync('yarn install --no-lockfile', {
58+
cwd: __dirname,
59+
stdio: 'inherit',
60+
});
5861
});
59-
});
6062

61-
Promise.resolve().then(() => console.log(`Requested "react" version: "${requestedReactVersion}"`)).then(deleteExistingDependencies()).then(preparePackageJson(requestedReactVersion)).then(installDependencies()).catch(err => console.error(err));
63+
Promise.resolve()
64+
.then(() =>
65+
console.log(`Requested "react" version: "${requestedReactVersion}"`)
66+
)
67+
.then(deleteExistingDependencies())
68+
.then(preparePackageJson(requestedReactVersion))
69+
.then(installDependencies())
70+
.catch((err) => console.error(err));
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
#!/usr/bin/env node
22

33
const execFileSync = require('child_process').execFileSync;
4-
54
const path = require('path');
65

76
const buildType = process.argv[2];
8-
97
if (!buildType) {
108
throw new Error('The build type to test is missing');
119
}
1210

1311
const requestedReactVersion = process.argv[3];
14-
1512
if (!requestedReactVersion) {
1613
throw new Error('React version to use for the test is missing');
1714
}
1815

1916
execFileSync(path.join(__dirname, 'prepare.js'), [requestedReactVersion], {
2017
cwd: __dirname,
21-
stdio: 'inherit'
18+
stdio: 'inherit',
2219
});
20+
2321
execFileSync(path.join(__dirname, 'smoke.js'), [buildType], {
2422
cwd: __dirname,
25-
stdio: 'inherit'
26-
});
23+
stdio: 'inherit',
24+
});
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/usr/bin/env node
22

33
/* eslint-disable no-console, import/no-extraneous-dependencies, no-global-assign */
4+
45
require = require('esm')(module);
56

6-
const requireReactElementToJsxString = buildType => {
7+
const requireReactElementToJsxString = (buildType) => {
78
if (buildType === 'esm') {
89
return require(`./../../dist/esm`).default;
910
} else if (buildType === 'cjs') {
@@ -14,16 +15,21 @@ const requireReactElementToJsxString = buildType => {
1415
};
1516

1617
const expect = require('expect');
17-
1818
const React = require('react');
19-
2019
const reactElementToJsxString = requireReactElementToJsxString(process.argv[2]);
20+
2121
console.log(`Tested "react" version: "${React.version}"`);
22-
const tree = React.createElement('div', {
23-
foo: 51
24-
}, React.createElement('h1', {}, 'Hello world'));
25-
expect(reactElementToJsxString(tree)).toEqual(`<div foo={51}>
22+
23+
const tree = React.createElement(
24+
'div',
25+
{ foo: 51 },
26+
React.createElement('h1', {}, 'Hello world')
27+
);
28+
29+
expect(reactElementToJsxString(tree)).toEqual(
30+
`<div foo={51}>
2631
<h1>
2732
Hello world
2833
</h1>
29-
</div>`);
34+
</div>`
35+
);

0 commit comments

Comments
 (0)