QUnit.done()

version added: 1.0.0.

Description

QUnit.done( callback )

Register a callback to fire when the test run has ended. The callback may be an async function, or a function that return a Promise which will be waited for before the next callback is handled.

parameter description
callback (function) Callback to execute, called with a details object:

Details object

property description
failed (number) Number of failed assertions
passed (number) Number of passed assertions
total (number) Total number of assertions
runtime (number) Duration of the test run in milliseconds

Use of details is discouraged and it’s recommended to use QUnit.on('runEnd') instead.

Caveats:

  • This callback reports the internal assertion count.

  • The default browser and CLI interfaces for QUnit and other popular test frameworks, and most CI integrations, report the number of tests. Reporting the number assertions may be confusing to developers.

  • Failed assertions of a test.todo() test are reported exactly as such. While rare, this means that a test run and all tests within it may be reported as passing, while internally there were some failed assertions. Unfortunately, this internal detail is exposed for compatibility reasons.

Changelog

QUnit 2.2 Discourage details parameter in favour of QUnit.on('runEnd').

Examples

Register a callback that logs internal assertion counts.

QUnit.done(function (details) {
  console.log('Runtime: ' + details.runtime);
});