Skip to content

Latest commit

 

History

History
62 lines (50 loc) · 1.82 KB

QUnit.testDone.md

File metadata and controls

62 lines (50 loc) · 1.82 KB
layout title excerpt groups redirect_from version_added
page-api
QUnit.testDone()
Register a callback to fire whenever a test ends.
callbacks
/callbacks/QUnit.testDone/
/QUnit.testDone/
1.0.0

QUnit.testDone( callback )

Register a callback to fire whenever a test ends. 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. Provides a single argument with the callback Details object

Details object

Passed to the callback:

property description
name (string) Name of the current test
module (string) Name of the current module
failed (number) The number of failed assertions
passed (number) The number of passed assertions
total (number) The total number of assertions
runtime (number) The execution time in milliseconds of the test, including beforeEach and afterEach calls
skipped (boolean) Indicates whether or not the current test was skipped
todo (boolean) Indicates whether or not the current test was a todo
testId (string) Internal ID of the current test

Changelog

| QUnit 1.16 | Added details.testId property.

Examples

Register a callback that logs results of a single test:

QUnit.testDone(details => {
  const result = {
    'Module name': details.module,
    'Test name': details.name,
    Assertions: {
      Total: details.total,
      Passed: details.passed,
      Failed: details.failed
    },
    Skipped: details.skipped,
    Todo: details.todo,
    Runtime: details.runtime
  };

  console.log(JSON.stringify(result, null, 2));
});