function reconcileUndeliveredResults
reconcileUndeliveredResults(
counter: Counter,
result: QUnitResult
): number

Reconciles the Node-side counter with QUnit's authoritative in-page tally after a run finishes, for a single-group run. Returns how many finished results the WebSocket stream failed to deliver (0 on a clean run).

QUnit is the source of truth for what ran; the testEnd stream is only the transport. A failure the stream dropped must still count (existing safety net), and when the browser finished more tests than the runner received, the remainder ran too — so trust QUnit's total rather than report the run as empty. Passes are derived as the remainder after the counts we did receive, which is exact for the common all-passing loss and best-effort if a skip/todo was also dropped.

const counter = { total: 2, failed: 0, skipped: 0, todo: 0, passed: 2, assertionsFailed: 0 };
const tally = { totalTests: 3, finishedTests: 3, failedTests: 1, currentTest: null };
reconcileUndeliveredResults(counter, tally); // 1 — one result never reached the runner
counter; // { total: 3, failed: 1, passed: 2, … } — QUnit's tally wins

Parameters

counter: Counter

Return Type

number

Usage

import { reconcileUndeliveredResults } from "lib/commands/test/tests-in-browser.ts";