function harness
harness(options: { timeout: number; }): void

Installs globalThis.__qunitxHarness: run the tests this page has registered, on command, and be ready for more.

Two things a page that is otherwise a test run does not do. First autostart: false, merged by QUnit's own preconfig path, so tests wait to be asked instead of running on page load. Then ReplHarness.flush, which runs whatever has been registered and — the part QUnit does not offer — puts the queue back in a state that accepts the NEXT batch, so a session is many runs rather than one.

Both callers want the second; only the REPL needs the first. qunitx run injects this AFTER its bundle has evaluated, where the real QUnit already exists and the preconfig would overwrite it — hence the guard — and its tests are already sitting in the queue because the qunitx runtime turns autostart off itself.

import { harness } from './qunit-harness.ts';

// Defined, not invoked: it installs page globals and only makes sense inside a browser.
function inject(page: { addInitScript(script: { content: string }): Promise<void> }) {
  return page.addInitScript({ content: `(${harness.toString()})({ timeout: 20000 })` });
}

Parameters

options: { timeout: number; }

Return Type

void

Usage

import { harness } from "lib/setup/qunit-harness.ts";