Skip to content

armgit / mocha

Public Imported from GitHub
0

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

return the created test in `xit` for bdd interface; closes #3142 (#3143)

Ahmad Bamieh4c0df7014f31
diff --git a/appveyor.yml b/appveyor.yml
index 2fe1c21c..28da3062 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -9,6 +9,7 @@ install:
- set CI=true
- set PATH=%APPDATA%\npm;c:\MinGW\bin;%PATH%
- set PHANTOMJS_CDNURL=https://cnpmjs.org/downloads
+ - npm install -g npm
- npm install
- copy c:\MinGW\bin\mingw32-make.exe c:\MinGW\bin\make.exe
matrix:
diff --git a/lib/interfaces/bdd.js b/lib/interfaces/bdd.js
index 33efc169..7a54375a 100644
--- a/lib/interfaces/bdd.js
+++ b/lib/interfaces/bdd.js
@@ -102,7 +102,7 @@ module.exports = function (suite) {
*/
context.xit = context.xspecify = context.it.skip = function (title) {
- context.it(title);
+ return context.it(title);
};
/**
diff --git a/test/integration/fixtures/pending/skip-shorthand.fixture.js b/test/integration/fixtures/pending/skip-shorthand.fixture.js
new file mode 100644
index 00000000..399dc48a
--- /dev/null
+++ b/test/integration/fixtures/pending/skip-shorthand.fixture.js
@@ -0,0 +1,7 @@
+'use strict';
+
+describe('pending shorthand', function () {
+ xit('pending spec', function () {}).timeout(0);
+ xspecify('pending spec', function () {}).timeout(0);
+ it.skip('pending spec', function () {}).timeout(0);
+});
diff --git a/test/integration/pending.spec.js b/test/integration/pending.spec.js
index f5a400f0..30cf61ce 100644
--- a/test/integration/pending.spec.js
+++ b/test/integration/pending.spec.js
@@ -19,6 +19,19 @@ describe('pending', function () {
done();
});
});
+ it('should return the test object when used via shorthand methods', function (done) {
+ run('pending/skip-shorthand.fixture.js', args, function (err, res) {
+ if (err) {
+ done(err);
+ return;
+ }
+ assert.equal(res.stats.pending, 3);
+ assert.equal(res.stats.passes, 0);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
});
describe('synchronous skip()', function () {
diff --git a/test/interfaces/bdd.spec.js b/test/interfaces/bdd.spec.js
index 2289c124..14365dc3 100644
--- a/test/interfaces/bdd.spec.js
+++ b/test/interfaces/bdd.spec.js
@@ -40,3 +40,27 @@ describe('pending suite', function () {
});
});
});
+
+describe('pending tests', function () {
+ it.skip('should not run', function () {
+ expect(1 + 1).to.equal(3);
+ });
+});
+
+describe('setting timeout by appending it to test', function () {
+ var runningTest = it('enables users to call timeout on active tests', function () {
+ expect(1 + 1).to.equal(2);
+ }).timeout(1003);
+
+ var skippedTest = xit('enables users to call timeout on pending tests', function () {
+ expect(1 + 1).to.equal(3);
+ }).timeout(1002);
+
+ it('sets timeout on pending tests', function () {
+ expect(skippedTest._timeout).to.equal(1002);
+ });
+
+ it('sets timeout on running tests', function () {
+ expect(runningTest._timeout).to.equal(1003);
+ });
+});