interface TestResult

One finished test.

const test: TestResult = {
  name: 'sums line items',
  modules: ['Cart', 'totals'],
  fullName: 'Cart > totals: sums line items',
  status: 'failed',
  durationMs: 12,
  assertions: [{ passed: false, todo: false, actual: 3, expected: 4 }],
  file: 'test/cart-test.ts',
};
test.fullName; // exactly the string `--filter` matches against

Properties

name: string

The test's own name, without its modules.

modules: string[]

The QUnit module path it was declared under; empty for a top-level test.

fullName: string

"Module > Sub: test name" — the string filter matches against.

status: "passed" | "failed" | "skipped" | "todo"

QUnit's outcome for this test.

durationMs: number

How long the test took, in milliseconds.

The test's assertions. QUnit trims these for passing tests, so this is populated for failures and empty otherwise — a passing test's assertion count is not reported.

file: string | null

Source file this test was declared in, relative to the project root, or null.

Populated for failures only, and that is a limit of what QUnit reports rather than a choice: testEnd carries no file, so the path is recovered from the failing assertion's stack through the bundle's source map. A passing test leaves no stack to map.

Usage

import { type TestResult } from "lib/api/test.ts";