seriesoftubes/scripts/test.js
Frederic Jung 67a40942b4
Split the game page into partials under src/, assembled into one index.html at build
site/index.html (900 KB of HTML, CSS and JS in one file) becomes src/: a shell
(src/index.html), styles/ and game/, concatenated in path order by
scripts/lib/page.js. The assembled page is byte-identical to the old file, so
load time and in-game performance are unchanged.

- scripts/build.js replaces build.sh (same env vars, same output)
- npm run dev: a zero-dependency dev server that assembles on every request
- tests assemble the page in memory; npm test runs every tests/*.test.js
- perf-bench takes --base-ref to build a git ref's page
- scripts/legacy/split-index-html.js is the splitter, kept for older branches
2026-10-27 10:05:56 +01:00

16 lines
923 B
JavaScript

#!/usr/bin/env node
// Runs every tests/*.test.js, one file at a time. New test files are picked up on their own, so adding
// one never touches package.json (and never conflicts with someone else adding theirs).
//
// npm test everything
// npm test -- tests/peering.test.js just these files (other arguments go to node --test)
const fs = require('node:fs');
const path = require('node:path');
const { spawnSync } = require('node:child_process');
const dir = path.join(__dirname, '..', 'tests');
const args = process.argv.slice(2);
const files = args.some((a) => a.endsWith('.test.js')) ? [] :
fs.readdirSync(dir).filter((f) => f.endsWith('.test.js')).sort().map((f) => path.join('tests', f));
const r = spawnSync(process.execPath, ['--test', '--test-concurrency=1', ...args, ...files], { stdio: 'inherit', cwd: path.join(__dirname, '..') });
process.exit(r.status ?? 1);