diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index ae6a513..bf254e9 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -20,18 +20,19 @@ concurrency: cancel-in-progress: false jobs: - release: + check: runs-on: ubuntu-latest env: GH_TOKEN: ${{ github.token }} + outputs: + skip: ${{ steps.v.outputs.skip }} + ver: ${{ steps.v.outputs.ver }} + tag: ${{ steps.v.outputs.tag }} + pre: ${{ steps.v.outputs.pre }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 - with: - node-version: 24 - cache: npm - name: Work out the version and whether it is new id: v @@ -57,34 +58,40 @@ jobs: case "$ver" in *-*) echo "pre=true" >> "$GITHUB_OUTPUT";; *) echo "pre=false" >> "$GITHUB_OUTPUT";; esac echo "skip=false" >> "$GITHUB_OUTPUT" - - name: Test before releasing - if: steps.v.outputs.skip == 'false' - run: npm ci && npm test + # The same tests as every push, split over several runners (ci.yml), before anything is tagged. + tests: + needs: check + if: needs.check.outputs.skip == 'false' + uses: ./.github/workflows/ci.yml + + release: + needs: [check, tests] + if: needs.check.outputs.skip == 'false' + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ needs.check.outputs.tag }} + VER: ${{ needs.check.outputs.ver }} + PRE: ${{ needs.check.outputs.pre }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Publish the release - if: steps.v.outputs.skip == 'false' - env: - TAG: ${{ steps.v.outputs.tag }} - VER: ${{ steps.v.outputs.ver }} - PRE: ${{ steps.v.outputs.pre }} run: | set -euo pipefail + awk -v v="$VER" 'index($0,"## ["v"]")==1{f=1;next} /^## \[/{f=0} f' CHANGELOG.md | sed -e '/./,$!d' > notes.md pre=(); [ "$PRE" = "true" ] && pre=(--prerelease) gh release create "$TAG" --repo "$GITHUB_REPOSITORY" \ --target "$GITHUB_SHA" --title "$VER" --notes-file notes.md "${pre[@]}" - name: Deploy it - # Pre-releases are for testing and never go live. - if: steps.v.outputs.skip == 'false' && steps.v.outputs.pre == 'false' - env: - TAG: ${{ steps.v.outputs.tag }} - run: gh workflow run release.yml --repo "$GITHUB_REPOSITORY" --ref "$TAG" -f tag="$TAG" + # Pre-releases are for testing and never go live. The tag was just tested above, so the deploy does not + # test it again (tested=true). + if: env.PRE == 'false' + run: gh workflow run release.yml --repo "$GITHUB_REPOSITORY" --ref "$TAG" -f tag="$TAG" -f tested=true - name: Publish the Docker image # Same pattern as the deploy above: the image is built and pushed from the # release tag by docker.yml. Pre-releases get one too: an image tag is # pulled on purpose, so a test image costs nothing. - if: steps.v.outputs.skip == 'false' - env: - TAG: ${{ steps.v.outputs.tag }} run: gh workflow run docker.yml --repo "$GITHUB_REPOSITORY" --ref "$TAG" -f tag="$TAG" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e135ebb..a70d674 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,44 +1,89 @@ name: CI +# Every push and PR, and the releases too (auto-release.yml and release.yml call this workflow), so the tests run +# one way, split over several runners, everywhere. on: push: branches: [main] pull_request: + workflow_call: + inputs: + ref: + description: The commit or tag to test (a release tag); the caller's commit when empty + type: string + default: '' permissions: contents: read # A newer push to the same pull request makes the older run pointless: cancel it instead of queueing behind it. -# Runs on main always finish. +# Runs on main always finish. A release's call gets a group of its own, so it never waits behind main's push run. concurrency: - group: ci-${{ github.ref }} + group: ci-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}${{ inputs.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} +env: + # Runners for the tests. Standard GitHub-hosted runners (4 cores each) are the only free ones for a public repo, + # and a run may use up to 20 at once, so more parts is how the tests get faster. Each part costs ~30 s of setup. + PARTS: 6 + jobs: - # The tests in four parts of about equal time, each on its own runner, each running as many files at once as - # it has cores (scripts/test.js; the split comes from tests/durations.json). + # Splits the test files into parts of about equal time, once, so every part works from the same plan. The times + # come from the last run on main (the cache, see "timings" below), else from the committed tests/durations.json. + plan: + runs-on: ubuntu-latest + outputs: + parts: ${{ steps.plan.outputs.parts }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ inputs.ref }} + - uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: tests/durations.json + key: test-durations-${{ github.run_id }} + restore-keys: test-durations- + - id: plan + run: echo "parts=$(node scripts/test.js --plan "$PARTS")" >> "$GITHUB_OUTPUT" + part: - name: test ${{ matrix.part }}/4 + name: part ${{ strategy.job-index }} + needs: plan runs-on: ubuntu-latest timeout-minutes: 20 strategy: fail-fast: false matrix: - part: [1, 2, 3, 4] + files: ${{ fromJSON(needs.plan.outputs.parts) }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ inputs.ref }} - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 cache: npm - run: npm ci - - run: npm test -- --shard ${{ matrix.part }}/4 + - name: Tests + env: + FILES: ${{ matrix.files }} + # Word splitting on purpose: FILES is a space-separated list of tests/*.test.js paths. + run: npm test -- --timings "$RUNNER_TEMP/timings.json" $FILES + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + if: always() + with: + name: timings-${{ strategy.job-index }} + path: ${{ runner.temp }}/timings.json + retention-days: 1 + if-no-files-found: ignore build: name: build runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ inputs.ref }} - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 @@ -47,21 +92,12 @@ jobs: - name: Build (not deployed — only releases deploy) run: npm run build - # The one check to look at, named as before: green only when every part and the build are. - test: - needs: [part, build] - if: always() - runs-on: ubuntu-latest - steps: - - name: Every part and the build passed - run: | - echo "parts: ${{ needs.part.result }}, build: ${{ needs.build.result }}" - test "${{ needs.part.result }}" = success && test "${{ needs.build.result }}" = success - translations: runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ inputs.ref }} - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 @@ -69,3 +105,38 @@ jobs: - run: npm ci - name: Translation coverage run: node scripts/i18n-check.js --summary "$GITHUB_STEP_SUMMARY" + + # The one check to look at: green only when the plan, every part, the build and the translations are. + test: + needs: [plan, part, build, translations] + if: always() + runs-on: ubuntu-latest + steps: + - name: Everything passed + run: | + echo "plan: ${{ needs.plan.result }}, parts: ${{ needs.part.result }}, build: ${{ needs.build.result }}, translations: ${{ needs.translations.result }}" + test "${{ needs.plan.result }}" = success && test "${{ needs.part.result }}" = success + test "${{ needs.build.result }}" = success && test "${{ needs.translations.result }}" = success + + # After a run on main: each file's time from this run goes into the cache, so the next run (main or a PR) splits + # its parts by today's tests. Nobody has to remember to refresh tests/durations.json. + timings: + needs: part + if: always() && github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.part.result != 'skipped' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: tests/durations.json + key: test-durations-${{ github.run_id }} + restore-keys: test-durations- + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + pattern: timings-* + path: ${{ runner.temp }}/timings + - run: node scripts/test-timings.js --merge "$RUNNER_TEMP/timings" + - uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: tests/durations.json + key: test-durations-${{ github.run_id }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b77850e..3d2acf5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,6 +23,10 @@ on: description: Only the weekly puzzles changed (weekly-puzzle.yml); the release itself was tested when it shipped type: boolean default: false + tested: + description: The tag's tests already passed (auto-release.yml tests it before tagging) + type: boolean + default: false # Least privilege: only the deploy job can write to Pages. permissions: @@ -33,9 +37,18 @@ concurrency: cancel-in-progress: false jobs: + # The release's tests, split over several runners like every push (ci.yml). Skipped when auto-release.yml has just + # run them on this tag, and for a weekly redeploy (the build step below tests the weekly files against the tag). + tests: + if: ${{ (github.event_name == 'workflow_dispatch' || !github.event.release.prerelease) && !inputs.weekly && !inputs.tested }} + uses: ./.github/workflows/ci.yml + with: + ref: ${{ github.event.release.tag_name || inputs.tag }} + build: + needs: tests # Pre-releases are for testing and never go live. - if: ${{ github.event_name == 'workflow_dispatch' || !github.event.release.prerelease }} + if: ${{ always() && (github.event_name == 'workflow_dispatch' || !github.event.release.prerelease) && (needs.tests.result == 'success' || needs.tests.result == 'skipped') }} runs-on: ubuntu-latest env: TAG: ${{ github.event.release.tag_name || inputs.tag }} @@ -93,10 +106,9 @@ jobs: node scripts/weekly-puzzle.js --check if [ -f scripts/weekly-scenario.js ]; then node scripts/weekly-scenario.js --check; fi if [ -f scripts/weekly-architect.js ]; then node scripts/weekly-architect.js --check; fi - - run: npm test - if: ${{ !inputs.weekly }} + # The weekly files come from main, not the tag: whatever tested the tag, they are tested against it here. - name: Test the weekly puzzles against this release - if: ${{ inputs.weekly && hashFiles('scripts/weekly-puzzle.js') != '' }} + if: ${{ hashFiles('scripts/weekly-puzzle.js') != '' }} run: npm test -- tests/weekly-puzzle.test.js tests/puzzles.test.js $(ls tests/weekly-scenario.test.js tests/weekly-architect.test.js 2>/dev/null) - name: Build site run: VERSION="${TAG#v}" REQUIRE_NOTES=1 npm run build diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 202c46f..2d10c00 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -80,9 +80,10 @@ Development runs on `npm run dev` (assembles the development page on every reque | `scripts/agent/relay.js`, `scripts/lib/mcp-browser.js`, `scripts/lib/relay-client.js` | The agent relay `npm run dev` hosts at `/agent`, and the MCP server's side of it: how a tool reaches the game in the player's tab | | `scripts/i18n-check.js`, `scripts/i18n-add.js`, `scripts/lib/dict.js` | Translation coverage and dictionary order; adding, renaming and removing entries | | `scripts/legacy/` | The splitter that made `src/` from the old `site/index.html` (and gave its text labels), and `port-branch.js`, which carries older branches over | -| `tests/harness.js` | Loads the assembled page in jsdom with a seeded `Math.random` and a fake canvas: the players' page, or the development page with `{agent: true}` | -| `.github/workflows/ci.yml` | Tests and build on every push and PR | -| `.github/workflows/auto-release.yml` | On a `package.json` version bump on `main`: test, tag, GitHub release from the CHANGELOG, start the deploy | +| `tests/harness.js` | Loads the assembled page in jsdom with a seeded `Math.random` and a fake canvas: the players' page, or the development page with `{agent: true}`. The page's scripts run straight in the window (jsdom's parser is slow on 2 MB of script) | +| `scripts/test.js`, `tests/durations.json` | Runs the tests, every file in its own process; splits them into parts of equal time for CI (`--plan`, `--shard`) by each file's seconds, which CI refreshes after every run on `main` | +| `.github/workflows/ci.yml` | Tests (split over 6 runners), build and translations on every push and PR; the releases call it too, so the tests run one way everywhere | +| `.github/workflows/auto-release.yml` | On a `package.json` version bump on `main`: test (ci.yml), tag, GitHub release from the CHANGELOG, start the deploy (already tested, so it does not test again) | | `.github/workflows/release.yml` | Builds and deploys to GitHub Pages, the only workflow that can | | `.github/workflows/weekly-puzzle.yml` | Sunday 03:37 UTC: makes the week's puzzle, commits it to `main` (data only, no release) and starts `release.yml` for the live release tag with `weekly=true` | | `scripts/weekly-puzzle.js`, `site/puzzles/weekly/` | The weekly puzzle generator and its output, one `.json` per week plus `index.json` (see below) | diff --git a/scripts/lib/timings-reporter.js b/scripts/lib/timings-reporter.js new file mode 100644 index 0000000..0341ee6 --- /dev/null +++ b/scripts/lib/timings-reporter.js @@ -0,0 +1,18 @@ +// A node:test reporter that writes how long each test file took, as JSON {"tests/x.test.js": seconds}, to its +// destination. scripts/test.js adds it next to the usual output with --timings FILE; CI merges the parts' files +// into tests/durations.json, which the next run splits its parts by. +const path = require('node:path'); + +module.exports = async function* timings(source) { + const sec = {}; + for await (const { type, data } of source) { + // Top-level tests only: their durations include their subtests. + if ((type === 'test:pass' || type === 'test:fail') && data.nesting === 0 && data.file && data.details) { + const f = path.relative(process.cwd(), data.file).split(path.sep).join('/'); + sec[f] = (sec[f] || 0) + (data.details.duration_ms || 0) / 1000; + } + } + const out = {}; + for (const f of Object.keys(sec).sort()) out[f] = Math.round(sec[f] * 10) / 10; + yield JSON.stringify(out, null, 1) + '\n'; +}; diff --git a/scripts/test-timings.js b/scripts/test-timings.js index 1bf7d5e..ed8cf48 100644 --- a/scripts/test-timings.js +++ b/scripts/test-timings.js @@ -5,6 +5,7 @@ // machine has cores, so absolute numbers vary, but their sizes relative to each other are what count. // // npm run test:timings +// node scripts/test-timings.js --merge DIR (CI) fold the parts' --timings files into it const fs = require('node:fs'); const os = require('node:os'); const path = require('node:path'); @@ -12,6 +13,24 @@ const { spawn } = require('node:child_process'); const root = path.join(__dirname, '..'); const dir = path.join(root, 'tests'); + +// --merge DIR: fold the timings CI's parts wrote (scripts/test.js --timings) into tests/durations.json. Files that are +// gone drop out; files no part ran keep their old time. +const mi = process.argv.indexOf('--merge'); +if (mi >= 0) { + const from = process.argv[mi + 1], dur = path.join(dir, 'durations.json'); + let out = {}; + try { out = JSON.parse(fs.readFileSync(dur, 'utf8')); } catch (e) { /* none yet */ } + let n = 0; + for (const f of fs.readdirSync(from, { recursive: true }).filter((f) => String(f).endsWith('.json'))) { + for (const [k, v] of Object.entries(JSON.parse(fs.readFileSync(path.join(from, String(f)), 'utf8')))) if (v > 0) { out[k] = v; n++; } + } + const have = new Set(fs.readdirSync(dir).filter((f) => f.endsWith('.test.js')).map((f) => 'tests/' + f)); + const sorted = Object.fromEntries(Object.keys(out).filter((k) => have.has(k)).sort().map((k) => [k, out[k]])); + fs.writeFileSync(dur, JSON.stringify(sorted, null, 1) + '\n'); + console.log(`merged ${n} timings; tests/durations.json has ${Object.keys(sorted).length} of ${have.size} files`); + process.exit(0); +} const files = fs.readdirSync(dir).filter((f) => f.endsWith('.test.js')).sort().map((f) => 'tests/' + f); const jobs = Math.max(1, parseInt(process.env.TEST_JOBS, 10) || os.availableParallelism()); const out = {}; diff --git a/scripts/test.js b/scripts/test.js index e847053..1232bd1 100644 --- a/scripts/test.js +++ b/scripts/test.js @@ -5,14 +5,18 @@ // // npm test everything // npm test -- tests/peering.test.js just these files (other arguments go to node --test) -// npm test -- --shard 2/4 one of four parts of about equal time (CI runs the four at once) +// npm test -- --shard 2/4 one of four parts of about equal time // npm test -- --shard 2/4 --list which files that part holds, without running them +// node scripts/test.js --plan 6 the split into 6 parts as JSON (CI's plan job: one list per runner) +// npm test -- --timings out.json also write each file's seconds to out.json (CI merges these into +// the durations the next run splits by) // TEST_JOBS=1 npm test one file at a time, as it used to be // npm test -- --stress 8 tests/x.test.js hunt a flaky test: 8 copies of these files at once, on a machine kept // busier than CI ever is, and how many runs failed (and why) // -// Parts are balanced by tests/durations.json, each file's typical seconds (refresh: npm run test:timings). -// A file missing from it counts as a typical one, so a stale list only makes the parts a little uneven. +// Parts are balanced by tests/durations.json, each file's typical seconds. CI keeps it fresh in its cache from every +// run on main (.github/workflows/ci.yml); npm run test:timings rewrites the committed copy. A file missing from it +// counts as a typical one, so a stale list only makes the parts a little uneven. const fs = require('node:fs'); const os = require('node:os'); const path = require('node:path'); @@ -31,6 +35,12 @@ if (ti >= 0) { if (!(stress >= 1)) { console.error('--stress wants a count, like --stress 8'); process.exit(2); } args.splice(ti, 2); } +let timings = null; +const tmi = args.indexOf('--timings'); +if (tmi >= 0) { timings = args[tmi + 1]; args.splice(tmi, 2); if (!timings) { console.error('--timings wants a file'); process.exit(2); } } +let plan = 0; +const pi = args.indexOf('--plan'); +if (pi >= 0) { plan = parseInt(args[pi + 1], 10); args.splice(pi, 2); if (!(plan >= 1)) { console.error('--plan wants a count, like --plan 6'); process.exit(2); } } let shard = null; const si = args.indexOf('--shard'); if (si >= 0) { @@ -58,6 +68,10 @@ function part(list, i, n) { } return out[i - 1].sort(); } +if (plan) { + console.log(JSON.stringify(Array.from({ length: plan }, (_, i) => part(files, i + 1, plan).join(' ')))); + process.exit(0); +} if (shard && files.length) { files = part(files, shard[0], shard[1]); console.log(`# part ${shard[0]}/${shard[1]}: ${files.length} files`); @@ -84,5 +98,7 @@ if (stress) { }); return; } -const r = spawnSync(process.execPath, ['--test', `--test-concurrency=${jobs}`, ...args, ...files], { stdio: 'inherit', cwd: root }); +const rep = timings ? ['--test-reporter=spec', '--test-reporter-destination=stdout', + `--test-reporter=${path.join(__dirname, 'lib', 'timings-reporter.js')}`, `--test-reporter-destination=${timings}`] : []; +const r = spawnSync(process.execPath, ['--test', `--test-concurrency=${jobs}`, ...rep, ...args, ...files], { stdio: 'inherit', cwd: root }); process.exit(r.status ?? 1); diff --git a/tests/backbone-core.test.js b/tests/backbone-core.test.js index 10611a1..f3cea64 100644 --- a/tests/backbone-core.test.js +++ b/tests/backbone-core.test.js @@ -38,9 +38,10 @@ test('a new network runs plain IGP: no Auto-TE until the backbone is upgraded, o assert.deepEqual(JSON.parse(ev('JSON.stringify(S.core)')), { lv: 0, run: 0 }); ev('ACT.buyTE()'); assert.equal(ev('!!S.te'), false, 'no Auto-TE on plain IGP'); - ev("ACT.leftTab({t:'noc'})"); - assert.match(dom.window.document.body.textContent, /Backbone/); - assert.match(dom.window.document.body.textContent, /Auto-TE needs an RSVP-TE/); + // The backbone lives in the NOC's routing window; the refusal is a toast. + ev('ACT.routingOpen()'); + assert.match(dom.window.document.getElementById('modal').textContent, /Backbone/); + assert.match(dom.window.document.getElementById('toasts').textContent, /Auto-TE needs an RSVP-TE/); const cash = ev('S.cash'); ev('ACT.coreUp()'); assert.equal(ev('S.core.lv'), 1); diff --git a/tests/calendar.test.js b/tests/calendar.test.js index 18bea1e..40d8e19 100644 --- a/tests/calendar.test.js +++ b/tests/calendar.test.js @@ -23,14 +23,6 @@ test('#257 the calendar has real months and leap years',()=>{ assert.deepEqual(errors,[]); }finally{dom.window.close();} }); -test('#257 a calendar month costs its monthly price, whatever its length',()=>{ - const {ev,dom}=load();try{ - ev("ACT.start({});S.day=31");// 1 February Y1 - const before=ev('S.cash'),net=ev('R.revMo-R.costMo'); - ev("for(let i=0;i<28;i++)S.cash+=(R.revMo-R.costMo)/monLen(S.day+i)"); - assert.ok(Math.abs(ev('S.cash')-before-net)<1e-6,'28 days of February add up to one month'); - }finally{dom.window.close();} -}); test('#257 loan statements and the intern budget follow calendar months',()=>{ const {ev,dom}=load();try{ ev("ACT.start({})"); diff --git a/tests/game.test.js b/tests/game.test.js index aa21ff1..abf1247 100644 --- a/tests/game.test.js +++ b/tests/game.test.js @@ -15,12 +15,6 @@ test('every city sits on its landmass', () => { assert.equal(off, ''); }); -test('every cable lands at two known cities and has a length', () => { - const { ev } = load(); - const bad = ev("CABLE_PAIRS.filter(c=>!CITY[c.a]||!CITY[c.b]||!(c.km>0)).map(c=>c.cid).join()"); - assert.equal(bad, ''); -}); - test('a year of scripted play stays healthy', () => { const { ev, errors } = load(); seed(ev, 7); diff --git a/tests/harness.js b/tests/harness.js index a9f897a..2e5c0a2 100644 --- a/tests/harness.js +++ b/tests/harness.js @@ -6,12 +6,33 @@ // it fails here rather than in production. const fs = require('node:fs'); const path = require('node:path'); +const vm = require('node:vm'); const { JSDOM, VirtualConsole } = require('jsdom'); const { assemble } = require('../scripts/lib/page'); const PAGE = {}; const page = (dev) => PAGE[dev] || (PAGE[dev] = assemble({ dev }).html); +// The page's inline scripts, taken out of the HTML once per process and compiled once. jsdom's HTML parser is slow +// on 2 MB of script text (it was more than half of every load()), so the DOM is built from the rest of the page and +// the scripts then run in its window, in order, the same way jsdom runs them (vm.Script.runInContext). Only plain +// '; + }); + // With scripting on, the parser keeps a