diff --git a/docs/QUnit/test.md b/docs/QUnit/test.md index d7b298628..cd5572336 100644 --- a/docs/QUnit/test.md +++ b/docs/QUnit/test.md @@ -14,6 +14,9 @@ version_added: "1.0" --- `QUnit.test( name, callback )` +`QUnit.test.only( name, callback )`
+`QUnit.test.skip( name, callback )`
+`QUnit.test.todo( name, callback )` Add a test to run. @@ -28,6 +31,12 @@ Add a test to run. |-----------|-------------| | `assert` (object) | A new instance object with the [assertion methods](../assert/index.md) | +The `only`, `skip`, and `todo` variants of `QUnit.test` are aliases to the respective main QUnit methods:
+ +* `QUnit.test.only()` is the same as [`QUnit.only()`](./only.md) +* `QUnit.test.skip()` is the same as [`QUnit.skip()`](./skip.md) +* `QUnit.test.todo()` is the same as [`QUnit.todo()`](./todo.md) + ### Description Add a test to run using `QUnit.test()`. diff --git a/src/core.js b/src/core.js index ecb2710a7..d3e88587f 100644 --- a/src/core.js +++ b/src/core.js @@ -4,7 +4,7 @@ import equiv from "./equiv"; import dump from "./dump"; import module from "./module"; import Assert from "./assert"; -import Test, { test, skip, only, todo, pushFailure } from "./test"; +import Test, { test, pushFailure } from "./test"; import exportQUnit from "./export"; import config from "./core/config"; @@ -43,11 +43,10 @@ extend( QUnit, { test: test, - todo: todo, - - skip: skip, - - only: only, + // alias other test flavors for easy access + todo: test.todo, + skip: test.skip, + only: test.only, start: function( count ) { var globalStartAlreadyCalled = globalStartCalled; diff --git a/src/test.js b/src/test.js index fc4bc21d3..e86470668 100644 --- a/src/test.js +++ b/src/test.js @@ -689,48 +689,46 @@ export function test( testName, callback ) { newTest.queue(); } -export function todo( testName, callback ) { - if ( focused ) { - return; - } +extend( test, { + todo: function todo( testName, callback ) { + if ( focused ) { + return; + } - const newTest = new Test( { - testName, - callback, - todo: true - } ); + const newTest = new Test( { + testName, + callback, + todo: true + } ); - newTest.queue(); -} + newTest.queue(); + }, + skip: function skip( testName ) { + if ( focused ) { + return; + } -// Will be exposed as QUnit.skip -export function skip( testName ) { - if ( focused ) { - return; - } + const test = new Test( { + testName: testName, + skip: true + } ); - const test = new Test( { - testName: testName, - skip: true - } ); + test.queue(); + }, + only: function only( testName, callback ) { + if ( !focused ) { + config.queue.length = 0; + focused = true; + } - test.queue(); -} + const newTest = new Test( { + testName: testName, + callback: callback + } ); -// Will be exposed as QUnit.only -export function only( testName, callback ) { - if ( !focused ) { - config.queue.length = 0; - focused = true; + newTest.queue(); } - - const newTest = new Test( { - testName: testName, - callback: callback - } ); - - newTest.queue(); -} +} ); // Resets config.timeout with a new timeout duration. export function resetTestTimeout( timeoutDuration ) { diff --git a/test/main/test.js b/test/main/test.js index 6aac7307a..b97671758 100644 --- a/test/main/test.js +++ b/test/main/test.js @@ -193,6 +193,15 @@ QUnit.test( "testForPush", function( assert ) { assert.testForPush( 1, 1, "should be call pushResult" ); } ); +QUnit.module( "aliases" ); + +[ "todo", "skip", "only" ].forEach( function( flavor ) { + QUnit.test( flavor, function( assert ) { + assert.true( QUnit.test[ flavor ] instanceof Function ); + assert.equal( QUnit[ flavor ], QUnit.test[ flavor ] ); + } ); +} ); + QUnit.module( "QUnit.skip", { beforeEach: function( assert ) {