QUnit.test.skip()

version added: 1.16.0.

Description

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

Define a test that will be skipped. Use this to disable a known broken or “flaky” test case.

parameter description
name (string) Title of unit
callback (function) Optional, function that would perform the test

The callback and any module hooks do not run for a skipped test. The name of your test will be included in results as a “skipped” test. This serves as a reminder to contributors. This is often preferred over the alternative of commenting out a test, because the code in the test will remain discoverable through static analysis and code search, and encourages inclusion during refactors and IDE automation.

In larger codebases, you may need to temporarily disable a group of tests at once. You can use QUnit.module.skip() to recursively skip all tests in a module.

See also

Changelog

QUnit 2.12 The QUnit.skip() method was renamed to QUnit.test.skip().
Use of QUnit.skip() remains supported as an alias.
QUnit 1.16 The QUnit.skip() method was introduced.

Examples

How to use skip as a placeholder for future tests, or to temporarily skip a broken test.

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

  QUnit.test('say', (assert) => {
    assert.strictEqual(robot.say(), 'Exterminate!');
  });

  // Robot does not yet have a laser() method yet, skip this test for now
  QUnit.test.skip('laser', (assert) => {
    assert.true(robot.laser());
  });

  // TODO: Implement this later!
  QUnit.test.skip('jump');
});