Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 23 additions & 14 deletions lib/mocha.js
Expand Up @@ -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;
Expand All @@ -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);
};

/**
Expand Down
4 changes: 2 additions & 2 deletions test/integration/fixtures/common-js-require.fixture.js
Expand Up @@ -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');
});
Expand Down