|
| 1 | +#!/usr/bin/env node |
| 2 | + |
1 | 3 | import fs from "node:fs/promises"; |
2 | 4 | import jsdom, { JSDOM } from "jsdom"; |
3 | 5 | import path from "node:path"; |
4 | 6 | import { fileURLToPath } from "node:url"; |
| 7 | +import { runRollupEsmAndCommonJs, runRollupPureEsm } from "./lib/run-rollup.js"; |
| 8 | +import { runWebpack } from "./lib/run-webpack.js"; |
| 9 | +import { cleanTmpBundlersDir } from "./lib/utils.js"; |
5 | 10 |
|
6 | 11 | const dirname = path.dirname( fileURLToPath( import.meta.url ) ); |
7 | 12 |
|
8 | 13 | async function runJSDOMTest( { title, folder } ) { |
9 | | - console.log( "\nRunning bundlers tests:", title ); |
| 14 | + console.log( "Running bundlers tests:", title ); |
10 | 15 |
|
11 | 16 | const template = await fs.readFile( `${ dirname }/test.html`, "utf-8" ); |
12 | 17 | const scriptSource = await fs.readFile( |
@@ -37,17 +42,34 @@ async function runJSDOMTest( { title, folder } ) { |
37 | 42 | } |
38 | 43 | } |
39 | 44 |
|
40 | | -await runJSDOMTest( { |
41 | | - title: "Rollup with pure ESM setup", |
42 | | - folder: "rollup-pure-esm" |
43 | | -} ); |
| 45 | +async function buildAndTest() { |
| 46 | + await cleanTmpBundlersDir(); |
| 47 | + |
| 48 | + await Promise.all( [ |
| 49 | + runRollupPureEsm(), |
| 50 | + runRollupEsmAndCommonJs(), |
| 51 | + runWebpack() |
| 52 | + ] ); |
| 53 | + |
| 54 | + await Promise.all( [ |
| 55 | + runJSDOMTest( { |
| 56 | + title: "Rollup with pure ESM setup", |
| 57 | + folder: "rollup-pure-esm" |
| 58 | + } ), |
44 | 59 |
|
45 | | -await runJSDOMTest( { |
46 | | - title: "Rollup with ESM + CommonJS", |
47 | | - folder: "rollup-commonjs" |
48 | | -} ); |
| 60 | + runJSDOMTest( { |
| 61 | + title: "Rollup with ESM + CommonJS", |
| 62 | + folder: "rollup-commonjs" |
| 63 | + } ), |
| 64 | + |
| 65 | + runJSDOMTest( { |
| 66 | + title: "Webpack", |
| 67 | + folder: "webpack" |
| 68 | + } ) |
| 69 | + ] ); |
| 70 | + |
| 71 | + // The directory won't be cleaned in case of failures; this may aid debugging. |
| 72 | + await cleanTmpBundlersDir(); |
| 73 | +} |
49 | 74 |
|
50 | | -await runJSDOMTest( { |
51 | | - title: "Webpack", |
52 | | - folder: "webpack" |
53 | | -} ); |
| 75 | +await buildAndTest(); |
0 commit comments