Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Implement `suite.skip()`

Mike Pennisif06049bdf096
diff --git a/lib/interfaces/tdd.js b/lib/interfaces/tdd.js
index e3d5ef26..7bf838b3 100644
--- a/lib/interfaces/tdd.js
+++ b/lib/interfaces/tdd.js
@@ -82,6 +82,17 @@ module.exports = function(suite){
return suite;
};
+ /**
+ * Pending suite.
+ */
+ context.suite.skip = function(title, fn) {
+ var suite = Suite.create(suites[0], title);
+ suite.pending = true;
+ suites.unshift(suite);
+ fn.call(suite);
+ suites.shift();
+ };
+
/**
* Exclusive test-case.
*/
@@ -98,8 +109,10 @@ module.exports = function(suite){
*/
context.test = function(title, fn){
+ var suite = suites[0];
+ if (suite.pending) var fn = null;
var test = new Test(title, fn);
- suites[0].addTest(test);
+ suite.addTest(test);
return test;
};
diff --git a/test/acceptance/interfaces/tdd.js b/test/acceptance/interfaces/tdd.js
index 906b0558..33311dd6 100644
--- a/test/acceptance/interfaces/tdd.js
+++ b/test/acceptance/interfaces/tdd.js
@@ -27,6 +27,13 @@ suite('Array', function(){
zero.should.equal(1, 'this test should have been skipped');
});
+ suite.skip('should skip this suite', function(){
+ test('should skip this test', function(){
+ var zero = 0;
+ zero.should.equal(1, 'this test should have been skipped');
+ });
+ });
+
suiteTeardown(function(done){
initialValue.should.eql(42);
done();