QUnit.test.todo()
version added: 2.2.0.
Description
QUnit.test.todo( name, callback )
QUnit.todo( name, callback )
Define a test that is not yet expected to pass. Use this for tests of unfinished code.
| parameter | description |
|---|---|
name (string) |
Title of unit being tested |
callback (function) |
Function that performs the test |
Callback parameters
| parameter | description |
|---|---|
assert (object) |
A new instance object with the assertion methods |
In test-driven development, you can specify how code should work with tests, and then work towards making these tests pass. When collaborating in a larger project, you can share tests for unfinished features as “todo” tests so that CI passes while your feature is under development. You can also use this method to disable a known broken test, where the code may be working but the test is incomplete.
“Todo” tests will pass as long as there is at least one assertion still failing, or if an exception is thrown.
Once all assertions are passing, the “todo” test will fail, thus reminding you that QUnit.test.todo() should be changed to QUnit.test(). If a test should be skipped unconditionally, use QUnit.test.skip() instead.
You can 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. |
Examples
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
QUnit.test.todo('fireLazer', (assert) => {
const result = robot.fireLazer();
assert.equal(result, "I'm firing my lazer!");
});
});