QUnit.only()


QUnit.only( name, callback )

Description: Adds a test to exclusively run, preventing all other tests from running.

Use this method to focus your test suite on a specific test. QUnit.only will cause any other tests in your suite to be ignored.

Note, that if more than one QUnit.only is present only the first instance will run.

This is an alternative to filtering tests to run in the HTML reporter. It is especially useful when you use a console reporter or in a codebase with a large set of long running tests.

Example:

How to use QUnit.only to filter your test suite.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
QUnit.module( "robot", {
beforeEach: function() {
this.robot = new Robot();
}
});
QUnit.test( "say", function( assert ) {
assert.ok( false, "I'm not quite ready yet" );
});
QUnit.test( "stomp", function( assert ) {
assert.ok( false, "I'm not quite ready yet" );
});
// You're currently working on the laser feature, so we run only this test
QUnit.only( "laser", function( assert ) {
assert.ok( this.robot.laser() );
});