aboutsummaryrefslogtreecommitdiff
path: root/scripts/cmd/test.js
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/cmd/test.js')
-rw-r--r--scripts/cmd/test.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/cmd/test.js b/scripts/cmd/test.js
index 84f6d9742..4e3b6c6ca 100644
--- a/scripts/cmd/test.js
+++ b/scripts/cmd/test.js
@@ -1,5 +1,8 @@
import { run } from 'node:test';
import { spec } from 'node:test/reporters';
+import fs from 'node:fs/promises';
+import path from 'node:path';
+import { pathToFileURL } from 'node:url';
import arg from 'arg';
import glob from 'tiny-glob';
@@ -36,6 +39,20 @@ export default async function test() {
process.env.NODE_OPTIONS += ' --test-only';
}
+ if (!args['--parallel']) {
+ // If not parallel, we create a temporary file that imports all the test files
+ // so that it all runs in a single process.
+ const tempTestFile = path.resolve('./node_modules/.astro/test.mjs');
+ await fs.mkdir(path.dirname(tempTestFile), { recursive: true });
+ await fs.writeFile(
+ tempTestFile,
+ files.map((f) => `import ${JSON.stringify(pathToFileURL(f).toString())};`).join('\n')
+ );
+
+ files.length = 0;
+ files.push(tempTestFile);
+ }
+
// https://nodejs.org/api/test.html#runoptions
run({
files,