Skip to content

Commit

Permalink
Core: Implements QUnit.skip
Browse files Browse the repository at this point in the history
  • Loading branch information
leobalter committed Sep 4, 2014
1 parent 76ff48c commit 73712a9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,25 @@ QUnit = {
test.queue();
},

skip: function( testName ) {
var test = new Test({
skip: true,
testName: testName,
expected: 0,
async: false,
callback: function() {},
module: config.currentModule,
moduleTestEnvironment: config.currentModuleTestEnvironment,
stack: sourceFromStacktrace( 2 )
});

if ( !validTest( test ) ) {
return;
}

test.queue();
},

start: function( count ) {
var message;

Expand Down
15 changes: 14 additions & 1 deletion src/test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
function Test( settings ) {
var method, skippedAssertion;

extend( this, settings );
this.assert = new Assert( this );
this.assertions = [];
this.testNumber = ++Test.count;

skippedAssertion = function() {};

if ( settings.skip ) {
this.assert = {};
this.testName = "SKIPPED - " + this.testName;
for ( method in Assert.prototype ) {
this.assert[ method ] = skippedAssertion;
}
} else {
this.assert = new Assert( this );
}
}

Test.count = 0;
Expand Down
20 changes: 20 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,23 @@ QUnit.test( "mod2", function( assert ) {
assert.mod2( 2, 0, "2 % 2 == 0" );
assert.mod2( 3, 1, "3 % 2 == 1" );
});

QUnit.module( "Skipped tests", {
beforeEach: function( assert ) {

// skip assertions on test hooks for skipped tests
assert.ok( false, "skipped function" );
},
afterEach: function( assert ) {
assert.ok( false, "skipped function" );
}
});

QUnit.skip( "assertions are skipped", function( assert ) {

// this test callback won't run, even with broken code
assert.expect( 1000 );
throw "Error";
});

QUnit.skip ( "no function" );

0 comments on commit 73712a9

Please sign in to comment.