-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
51 lines (41 loc) · 1.47 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* Run each bundle, ensure all outputs match `src/app-default.js`
*/
import { execSync } from 'node:child_process';
const run = (path) => execSync(`node ${path}`, { encoding: 'utf8' });
const assertEqual = (expected, observed, description) => {
if (expected !== observed) {
console.error(description);
console.error(`Expected:
${expected}`);
console.error(`Observed:
${observed}`);
process.exit(1);
}
};
const expected = run('src/app-default.js');
const shakable = run('src/app-shakable.js');
assertEqual(
expected,
shakable,
'src/app-shakable.js logged different output than src/app-default.js'
);
console.log(
'✅ src/app-shakable.js produces the same output as src/app-default.js'
);
const esbuild = run('bundlers/esbuild/app-shakable.js');
assertEqual(expected, esbuild, 'esbuild logged unexpected output');
console.log('✅ esbuild');
const parcel = run('bundlers/parcel/app-shakable.js');
assertEqual(expected, parcel, 'parcel logged unexpected output');
console.log('✅ parcel');
const rollup = run('bundlers/rollup/app-shakable.js');
assertEqual(expected, rollup, 'rollup logged unexpected output');
console.log('✅ rollup');
const terser = run('bundlers/terser/app-shakable.js');
assertEqual(expected, terser, 'terser logged unexpected output');
console.log('✅ terser');
const webpack = run('bundlers/webpack/main.mjs');
assertEqual(expected, webpack, 'webpack logged unexpected output');
console.log('✅ webpack');
console.log('All tests passed.');