QUnit.config

General configuration options for QUnit.

Preconfiguring QUnit

If you load QUnit asynchronously or otherwise need to configure QUnit before it is loaded, you can predefine the configuration by creating a global variable QUnit with a config property.

The config values specified here will be carried over to the real QUnit.config object. Any other properties of this object will be ignored.

// Implicit global
// Supported everywhere, including old browsers. (But not ES strict mode.)
QUnit = {
  config: {
    autostart: false,
    maxDepth: 12
  }
};

// Browser global
// For all browsers (including strict mode and old browsers)
window.QUnit = { /* .. */ };

// Isomorphic global
// For modern browsers, SpiderMonkey, and Node.js (incl. strict mode).
globalThis.QUnit = { /* .. */ };

Changelog

QUnit 2.18.1 Preconfig support added for SpiderMonkey and other environments.
Previously, it was limited to the browser environment.
QUnit 2.1.0 Preconfig feature introduced.

QUnit.config.altertitle

Insert a success or failure symbol in the document title (HTML Reporter).

QUnit.config.autostart

Control when the test run may start.

QUnit.config.collapse

Collapse the details of failing tests after the first one (HTML Reporter).

QUnit.config.current

Internal object representing the currently running test.

QUnit.config.failOnZeroTests

Fail the test run if no tests were run.

QUnit.config.filter

Select tests to run based on a substring or pattern match.

QUnit.config.fixture

HTML content to render in the fixture container at the start of each test (HTML Reporter).

QUnit.config.hidepassed

Hide results of passed tests (HTML Reporter).

QUnit.config.maxDepth

The depth up-to which an object will be serialized during a diff (HTML Reporter).

QUnit.config.module

Select a single test module to run.

QUnit.config.moduleId

Select one or more modules to run, by their internal ID (HTML Reporter).

QUnit.config.modules

List of defined test modules.

QUnit.config.noglobals

Check the global object after each test and report new properties as failures.

QUnit.config.notrycatch

Disable handling of uncaught exceptions during tests.

QUnit.config.reorder

Allow re-running of previously failed tests out of order.

QUnit.config.requireExpects

Fail tests that don't specify how many assertions they expect.

QUnit.config.scrolltop

Scroll to the top of the page after the test run (HTML Reporter).

QUnit.config.seed

Enable randomized ordering of tests.

QUnit.config.storage

The Storage object to use for remembering failed tests between runs.

QUnit.config.testId

Select one or more tests to run, by their internal ID (HTML Reporter).

QUnit.config.testTimeout

Set a global default timeout after which a test will fail.

QUnit.config.urlConfig

Register additional input fields in the toolbar (HTML Reporter).