QUnit.test.todo()

version added: 2.2

QUnit.test.todo( name, callback )
QUnit.todo( name, callback )

Add a test which expects at least one failing assertion during its run.

parameter description
name (string) Title of unit being tested
callback (function) Function to close over assertions

Callback parameters: callback( assert ):

parameter description
assert (object) A new instance object with the assertion methods

Description

Use this method to test a unit of code that is still under development (in a “todo” state). The “todo” test will pass as long as there is at least one assertion still failing.

When all assertions are passing, the “todo” test will fail, thus signaling that QUnit.test.todo() should be changed to QUnit.test().

You can also use QUnit.module.todo() to manage the “todo” state for all tests within a module at once.

Changelog
QUnit 2.12 The QUnit.todo() method was renamed to QUnit.test.todo().
Use of QUnit.todo() remains supported as an alias.
QUnit 2.2 The QUnit.todo() method was introduced.

Example

How to use QUnit.test.todo to denote code that is still under development.

QUnit.module( "Robot", hooks => {
  let robot;
  hooks.beforeEach( () => {
    robot = new Robot();
  });

  // Robot is not yet finished, expect this is a todo test
  QUnit.test.todo( "fireLazer", assert => {
    const result = robot.fireLazer();
    assert.equal( result, "I'm firing my lazer!" );
  });
});