Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Fix: make it().timeout() work again (#4599)

Alexander Fenster6a4777617882
diff --git a/lib/mocha.js b/lib/mocha.js
index c1bd896b..fac1697c 100644
--- a/lib/mocha.js
+++ b/lib/mocha.js
@@ -98,37 +98,46 @@ exports.Test = require('./test');
let currentContext;
exports.afterEach = function(...args) {
- (currentContext.afterEach || currentContext.teardown).apply(this, args);
+ return (currentContext.afterEach || currentContext.teardown).apply(
+ this,
+ args
+ );
};
exports.after = function(...args) {
- (currentContext.after || currentContext.suiteTeardown).apply(this, args);
+ return (currentContext.after || currentContext.suiteTeardown).apply(
+ this,
+ args
+ );
};
exports.beforeEach = function(...args) {
- (currentContext.beforeEach || currentContext.setup).apply(this, args);
+ return (currentContext.beforeEach || currentContext.setup).apply(this, args);
};
exports.before = function(...args) {
- (currentContext.before || currentContext.suiteSetup).apply(this, args);
+ return (currentContext.before || currentContext.suiteSetup).apply(this, args);
};
exports.describe = function(...args) {
- (currentContext.describe || currentContext.suite).apply(this, args);
+ return (currentContext.describe || currentContext.suite).apply(this, args);
};
exports.describe.only = function(...args) {
- (currentContext.describe || currentContext.suite).only.apply(this, args);
+ return (currentContext.describe || currentContext.suite).only.apply(
+ this,
+ args
+ );
};
exports.describe.skip = function(...args) {
- (currentContext.describe || currentContext.suite).skip.apply(this, args);
+ return (currentContext.describe || currentContext.suite).skip.apply(
+ this,
+ args
+ );
};
exports.it = function(...args) {
- (currentContext.it || currentContext.test).apply(this, args);
+ return (currentContext.it || currentContext.test).apply(this, args);
};
exports.it.only = function(...args) {
- (currentContext.it || currentContext.test).only.apply(this, args);
+ return (currentContext.it || currentContext.test).only.apply(this, args);
};
exports.it.skip = function(...args) {
- (
- currentContext.xit ||
- (currentContext.test && currentContext.test.skip)
- ).apply(this, args);
+ return (currentContext.it || currentContext.test).skip.apply(this, args);
};
exports.xdescribe = exports.describe.skip;
exports.xit = exports.it.skip;
@@ -139,7 +148,7 @@ exports.suite = exports.describe;
exports.teardown = exports.afterEach;
exports.test = exports.it;
exports.run = function(...args) {
- currentContext.run.apply(this, args);
+ return currentContext.run.apply(this, args);
};
/**
diff --git a/test/integration/fixtures/common-js-require.fixture.js b/test/integration/fixtures/common-js-require.fixture.js
index 0573f6f0..17a0e62f 100644
--- a/test/integration/fixtures/common-js-require.fixture.js
+++ b/test/integration/fixtures/common-js-require.fixture.js
@@ -44,13 +44,13 @@ suite('root suite', () => {
describe.only('describe only', () => {
it('it', () => {
console.log('running it');
- });
+ }).timeout(1000);
xit('it', () => {
console.log('running xit');
});
it.only('it.only', () => {
console.log('running it.only');
- });
+ }).retries(2);
it.skip('it.skip', () => {
console.log('running it.skip');
});