default

QUnitX — universal test library that runs the same test file in Node.js, Deno, and browser.

Examples

Example 1

// math_test.js
import { module, test } from "qunitx";

module("Math", (hooks) => {
  hooks.beforeEach(function () {
    this.numbers = [1, 2, 3];
  });

  test("addition", function (assert) {
    assert.equal(this.numbers.reduce((sum, n) => sum + n, 0), 6);
  });

  test("async", async (assert) => {
    const n = await Promise.resolve(42);
    assert.strictEqual(n, 42);
  });
});

Both runtimes install it under the same name, so that one file runs on either. In a Deno project:

deno add qunitx

In a Node project:

npm install --save-dev qunitx

Then run it with whichever runner you have:

deno test math_test.js
node --test math_test.js

Example 2

// The same test written with the BDD aliases — describe and it are the same
// function objects as module and test, so everything above applies unchanged.
import { describe, it } from "qunitx";

describe("Math", (hooks) => {
  hooks.beforeEach(function () {
    this.numbers = [1, 2, 3];
  });

  it("addition", function (assert) {
    assert.equal(this.numbers.reduce((sum, n) => sum + n, 0), 6);
  });

  it("async", async (assert) => {
    const n = await Promise.resolve(42);
    assert.strictEqual(n, 42);
  });
});

describe.skip, it.skip, it.todo, runtime options, and nesting all behave identically to their module / test counterparts, and the commands above are unchanged.

Classes

c
Assert(
module: ModuleState | null,
test?: TestState
)

The assertion object passed to every test callback and lifecycle hook.

c
AssertionError(object: AssertionErrorOptions)

Thrown when an assertion fails. Extends Deno's built-in AssertionError so it integrates cleanly with Deno's test runner output.

Functions

f
describe.skipModule(
moduleName: string,
_moduleContent?: unknown
): void

Skips all tests inside a module. Equivalent to QUnit.module.skip. The module is registered as ignored by Deno's runner; no test bodies run.

f
describe.skipModule(
moduleName: string,
_moduleContent?: unknown
): void

Skips all tests inside a module. Equivalent to QUnit.module.skip. The module is registered as ignored by Deno's runner; no test bodies run.

f
describe.skipModule(
moduleName: string,
_moduleContent?: unknown
): void

Skips all tests inside a module. Equivalent to QUnit.module.skip. The module is registered as ignored by Deno's runner; no test bodies run.

f
describe.todoModule(
moduleName: string,
_moduleContent?: unknown
): void

Marks all tests inside a module as todo. Equivalent to QUnit.module.todo. The module is registered as ignored by Deno's runner; no test bodies run. Deno has no native "todo module" concept, so this maps to ignore.

f
describe.todoModule(
moduleName: string,
_moduleContent?: unknown
): void

Marks all tests inside a module as todo. Equivalent to QUnit.module.todo. The module is registered as ignored by Deno's runner; no test bodies run. Deno has no native "todo module" concept, so this maps to ignore.

f
describe.todoModule(
moduleName: string,
_moduleContent?: unknown
): void

Marks all tests inside a module as todo. Equivalent to QUnit.module.todo. The module is registered as ignored by Deno's runner; no test bodies run. Deno has no native "todo module" concept, so this maps to ignore.

f
it.skipTest(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to QUnit.test.skip. The test body is never executed; the test is reported as ignored by Deno's runner.

f
it.skipTest(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to QUnit.test.skip. The test body is never executed; the test is reported as ignored by Deno's runner.

f
it.skipTest(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to QUnit.test.skip. The test body is never executed; the test is reported as ignored by Deno's runner.

f
it.skipTest(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to QUnit.test.skip. The test body is never executed; the test is reported as ignored by Deno's runner.

f
it.skipTest(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to QUnit.test.skip. The test body is never executed; the test is reported as ignored by Deno's runner.

f
it.skipTest(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to QUnit.test.skip. The test body is never executed; the test is reported as ignored by Deno's runner.

f
it.skipTest(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to QUnit.test.skip. The test body is never executed; the test is reported as ignored by Deno's runner.

f
it.skipTest(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to QUnit.test.skip. The test body is never executed; the test is reported as ignored by Deno's runner.

f
it.skipTest(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to QUnit.test.skip. The test body is never executed; the test is reported as ignored by Deno's runner.

f
it.skipTest(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to QUnit.test.skip. The test body is never executed; the test is reported as ignored by Deno's runner.

f
it.skipTest(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to QUnit.test.skip. The test body is never executed; the test is reported as ignored by Deno's runner.

f
it.skipTest(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to QUnit.test.skip. The test body is never executed; the test is reported as ignored by Deno's runner.

f
it.todoTest(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to QUnit.test.todo. The test body is never executed; the test is reported as ignored by Deno's runner (Deno has no native todo concept).

f
it.todoTest(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to QUnit.test.todo. The test body is never executed; the test is reported as ignored by Deno's runner (Deno has no native todo concept).

f
it.todoTest(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to QUnit.test.todo. The test body is never executed; the test is reported as ignored by Deno's runner (Deno has no native todo concept).

f
it.todoTest(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to QUnit.test.todo. The test body is never executed; the test is reported as ignored by Deno's runner (Deno has no native todo concept).

f
it.todoTest(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to QUnit.test.todo. The test body is never executed; the test is reported as ignored by Deno's runner (Deno has no native todo concept).

f
it.todoTest(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to QUnit.test.todo. The test body is never executed; the test is reported as ignored by Deno's runner (Deno has no native todo concept).

f
it.todoTest(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to QUnit.test.todo. The test body is never executed; the test is reported as ignored by Deno's runner (Deno has no native todo concept).

f
it.todoTest(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to QUnit.test.todo. The test body is never executed; the test is reported as ignored by Deno's runner (Deno has no native todo concept).

f
it.todoTest(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to QUnit.test.todo. The test body is never executed; the test is reported as ignored by Deno's runner (Deno has no native todo concept).

f
it.todoTest(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to QUnit.test.todo. The test body is never executed; the test is reported as ignored by Deno's runner (Deno has no native todo concept).

f
it.todoTest(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to QUnit.test.todo. The test body is never executed; the test is reported as ignored by Deno's runner (Deno has no native todo concept).

f
it.todoTest(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to QUnit.test.todo. The test body is never executed; the test is reported as ignored by Deno's runner (Deno has no native todo concept).

f
module.skipModule(
moduleName: string,
_moduleContent?: unknown
): void

Skips all tests inside a module. Equivalent to QUnit.module.skip. The module is registered as ignored by Deno's runner; no test bodies run.

f
module.skipModule(
moduleName: string,
_moduleContent?: unknown
): void

Skips all tests inside a module. Equivalent to QUnit.module.skip. The module is registered as ignored by Deno's runner; no test bodies run.

f
module.skipModule(
moduleName: string,
_moduleContent?: unknown
): void

Skips all tests inside a module. Equivalent to QUnit.module.skip. The module is registered as ignored by Deno's runner; no test bodies run.

f
module.skipModule(
moduleName: string,
_moduleContent?: unknown
): void

Skips all tests inside a module. Equivalent to QUnit.module.skip. The module is registered as ignored by Deno's runner; no test bodies run.

f
module.skipModule(
moduleName: string,
_moduleContent?: unknown
): void

Skips all tests inside a module. Equivalent to QUnit.module.skip. The module is registered as ignored by Deno's runner; no test bodies run.

f
module.skipModule(
moduleName: string,
_moduleContent?: unknown
): void

Skips all tests inside a module. Equivalent to QUnit.module.skip. The module is registered as ignored by Deno's runner; no test bodies run.

f
module.skipModule(
moduleName: string,
_moduleContent?: unknown
): void

Skips all tests inside a module. Equivalent to QUnit.module.skip. The module is registered as ignored by Deno's runner; no test bodies run.

f
module.skipModule(
moduleName: string,
_moduleContent?: unknown
): void

Skips all tests inside a module. Equivalent to QUnit.module.skip. The module is registered as ignored by Deno's runner; no test bodies run.

f
module.skipModule(
moduleName: string,
_moduleContent?: unknown
): void

Skips all tests inside a module. Equivalent to QUnit.module.skip. The module is registered as ignored by Deno's runner; no test bodies run.

f
module.skipModule(
moduleName: string,
_moduleContent?: unknown
): void

Skips all tests inside a module. Equivalent to QUnit.module.skip. The module is registered as ignored by Deno's runner; no test bodies run.

f
module.skipModule(
moduleName: string,
_moduleContent?: unknown
): void

Skips all tests inside a module. Equivalent to QUnit.module.skip. The module is registered as ignored by Deno's runner; no test bodies run.

f
module.skipModule(
moduleName: string,
_moduleContent?: unknown
): void

Skips all tests inside a module. Equivalent to QUnit.module.skip. The module is registered as ignored by Deno's runner; no test bodies run.

f
module.todoModule(
moduleName: string,
_moduleContent?: unknown
): void

Marks all tests inside a module as todo. Equivalent to QUnit.module.todo. The module is registered as ignored by Deno's runner; no test bodies run. Deno has no native "todo module" concept, so this maps to ignore.

f
module.todoModule(
moduleName: string,
_moduleContent?: unknown
): void

Marks all tests inside a module as todo. Equivalent to QUnit.module.todo. The module is registered as ignored by Deno's runner; no test bodies run. Deno has no native "todo module" concept, so this maps to ignore.

f
module.todoModule(
moduleName: string,
_moduleContent?: unknown
): void

Marks all tests inside a module as todo. Equivalent to QUnit.module.todo. The module is registered as ignored by Deno's runner; no test bodies run. Deno has no native "todo module" concept, so this maps to ignore.

f
module.todoModule(
moduleName: string,
_moduleContent?: unknown
): void

Marks all tests inside a module as todo. Equivalent to QUnit.module.todo. The module is registered as ignored by Deno's runner; no test bodies run. Deno has no native "todo module" concept, so this maps to ignore.

f
module.todoModule(
moduleName: string,
_moduleContent?: unknown
): void

Marks all tests inside a module as todo. Equivalent to QUnit.module.todo. The module is registered as ignored by Deno's runner; no test bodies run. Deno has no native "todo module" concept, so this maps to ignore.

f
module.todoModule(
moduleName: string,
_moduleContent?: unknown
): void

Marks all tests inside a module as todo. Equivalent to QUnit.module.todo. The module is registered as ignored by Deno's runner; no test bodies run. Deno has no native "todo module" concept, so this maps to ignore.

f
module.todoModule(
moduleName: string,
_moduleContent?: unknown
): void

Marks all tests inside a module as todo. Equivalent to QUnit.module.todo. The module is registered as ignored by Deno's runner; no test bodies run. Deno has no native "todo module" concept, so this maps to ignore.

f
module.todoModule(
moduleName: string,
_moduleContent?: unknown
): void

Marks all tests inside a module as todo. Equivalent to QUnit.module.todo. The module is registered as ignored by Deno's runner; no test bodies run. Deno has no native "todo module" concept, so this maps to ignore.

f
module.todoModule(
moduleName: string,
_moduleContent?: unknown
): void

Marks all tests inside a module as todo. Equivalent to QUnit.module.todo. The module is registered as ignored by Deno's runner; no test bodies run. Deno has no native "todo module" concept, so this maps to ignore.

f
module.todoModule(
moduleName: string,
_moduleContent?: unknown
): void

Marks all tests inside a module as todo. Equivalent to QUnit.module.todo. The module is registered as ignored by Deno's runner; no test bodies run. Deno has no native "todo module" concept, so this maps to ignore.

f
module.todoModule(
moduleName: string,
_moduleContent?: unknown
): void

Marks all tests inside a module as todo. Equivalent to QUnit.module.todo. The module is registered as ignored by Deno's runner; no test bodies run. Deno has no native "todo module" concept, so this maps to ignore.

f
module.todoModule(
moduleName: string,
_moduleContent?: unknown
): void

Marks all tests inside a module as todo. Equivalent to QUnit.module.todo. The module is registered as ignored by Deno's runner; no test bodies run. Deno has no native "todo module" concept, so this maps to ignore.

f
skip(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to test.skip. The test body is never executed and the test is reported as ignored by Deno's runner.

f
test.skipTest(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to QUnit.test.skip. The test body is never executed; the test is reported as ignored by Deno's runner.

f
test.skipTest(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to QUnit.test.skip. The test body is never executed; the test is reported as ignored by Deno's runner.

f
test.skipTest(
testName: string,
_testContent?: unknown
): void

Registers a skipped test. Equivalent to QUnit.test.skip. The test body is never executed; the test is reported as ignored by Deno's runner.

f
test.todoTest(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to QUnit.test.todo. The test body is never executed; the test is reported as ignored by Deno's runner (Deno has no native todo concept).

f
test.todoTest(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to QUnit.test.todo. The test body is never executed; the test is reported as ignored by Deno's runner (Deno has no native todo concept).

f
test.todoTest(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to QUnit.test.todo. The test body is never executed; the test is reported as ignored by Deno's runner (Deno has no native todo concept).

f
todo(
testName: string,
_testContent?: unknown
): void

Registers a todo test. Equivalent to test.todo. The test body is never executed and the test is reported as ignored by Deno's runner, which has no native todo concept.

Interfaces

I
HooksObject

Lifecycle hooks available inside a module() callback.

I
PushResultInfo

Result object passed to Assert.prototype.pushResult.

Namespaces

N
describe

Additional properties on the describe function.

N
test

Additional properties on the test function.

Type Aliases

T
HookFn<A = unknown> = (
assert: A,
meta: { context: Record<string, unknown>; }
) => void | Promise<void>

A lifecycle hook callback that receives an Assert instance and a meta object with the shared context.

T
TestFn<A = unknown> = (
assert: A,
meta: { testName: string; options: unknown; context: Record<string, unknown>; }
) => void | Promise<unknown>

A test body: receives an Assert instance and a meta object naming the test, its runtime options, and the shared context.

Variables