Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Add test.only, test.skip to qunit interface

Glen Huang57fa4cbe3d70
diff --git a/lib/interfaces/qunit.js b/lib/interfaces/qunit.js
index 9376c84a..521a91cd 100644
--- a/lib/interfaces/qunit.js
+++ b/lib/interfaces/qunit.js
@@ -34,7 +34,7 @@ var Suite = require('../suite')
module.exports = function(suite){
var suites = [suite];
- suite.on('pre-require', function(context){
+ suite.on('pre-require', function(context, file, mocha){
/**
* Execute before running tests.
@@ -76,6 +76,16 @@ module.exports = function(suite){
if (suites.length > 1) suites.shift();
var suite = Suite.create(suites[0], title);
suites.unshift(suite);
+ return suite;
+ };
+
+ /**
+ * Exclusive test-case.
+ */
+
+ context.suite.only = function(title, fn){
+ var suite = context.suite(title, fn);
+ mocha.grep(suite.fullTitle());
};
/**
@@ -85,7 +95,26 @@ module.exports = function(suite){
*/
context.test = function(title, fn){
- suites[0].addTest(new Test(title, fn));
+ var test = new Test(title, fn);
+ suites[0].addTest(test);
+ return test;
+ };
+
+ /**
+ * Exclusive test-case.
+ */
+
+ context.test.only = function(title, fn){
+ var test = context.test(title, fn);
+ mocha.grep(test.fullTitle());
+ };
+
+ /**
+ * Pending test case.
+ */
+
+ context.test.skip = function(title){
+ context.test(title);
};
});
};