Skip to content

Commit 6a47776

Browse files
Fix: make it().timeout() work again (#4599)
1 parent 1de836b commit 6a47776

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

lib/mocha.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,37 +98,46 @@ exports.Test = require('./test');
9898

9999
let currentContext;
100100
exports.afterEach = function(...args) {
101-
(currentContext.afterEach || currentContext.teardown).apply(this, args);
101+
return (currentContext.afterEach || currentContext.teardown).apply(
102+
this,
103+
args
104+
);
102105
};
103106
exports.after = function(...args) {
104-
(currentContext.after || currentContext.suiteTeardown).apply(this, args);
107+
return (currentContext.after || currentContext.suiteTeardown).apply(
108+
this,
109+
args
110+
);
105111
};
106112
exports.beforeEach = function(...args) {
107-
(currentContext.beforeEach || currentContext.setup).apply(this, args);
113+
return (currentContext.beforeEach || currentContext.setup).apply(this, args);
108114
};
109115
exports.before = function(...args) {
110-
(currentContext.before || currentContext.suiteSetup).apply(this, args);
116+
return (currentContext.before || currentContext.suiteSetup).apply(this, args);
111117
};
112118
exports.describe = function(...args) {
113-
(currentContext.describe || currentContext.suite).apply(this, args);
119+
return (currentContext.describe || currentContext.suite).apply(this, args);
114120
};
115121
exports.describe.only = function(...args) {
116-
(currentContext.describe || currentContext.suite).only.apply(this, args);
122+
return (currentContext.describe || currentContext.suite).only.apply(
123+
this,
124+
args
125+
);
117126
};
118127
exports.describe.skip = function(...args) {
119-
(currentContext.describe || currentContext.suite).skip.apply(this, args);
128+
return (currentContext.describe || currentContext.suite).skip.apply(
129+
this,
130+
args
131+
);
120132
};
121133
exports.it = function(...args) {
122-
(currentContext.it || currentContext.test).apply(this, args);
134+
return (currentContext.it || currentContext.test).apply(this, args);
123135
};
124136
exports.it.only = function(...args) {
125-
(currentContext.it || currentContext.test).only.apply(this, args);
137+
return (currentContext.it || currentContext.test).only.apply(this, args);
126138
};
127139
exports.it.skip = function(...args) {
128-
(
129-
currentContext.xit ||
130-
(currentContext.test && currentContext.test.skip)
131-
).apply(this, args);
140+
return (currentContext.it || currentContext.test).skip.apply(this, args);
132141
};
133142
exports.xdescribe = exports.describe.skip;
134143
exports.xit = exports.it.skip;
@@ -139,7 +148,7 @@ exports.suite = exports.describe;
139148
exports.teardown = exports.afterEach;
140149
exports.test = exports.it;
141150
exports.run = function(...args) {
142-
currentContext.run.apply(this, args);
151+
return currentContext.run.apply(this, args);
143152
};
144153

145154
/**

test/integration/fixtures/common-js-require.fixture.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ suite('root suite', () => {
4444
describe.only('describe only', () => {
4545
it('it', () => {
4646
console.log('running it');
47-
});
47+
}).timeout(1000);
4848
xit('it', () => {
4949
console.log('running xit');
5050
});
5151
it.only('it.only', () => {
5252
console.log('running it.only');
53-
});
53+
}).retries(2);
5454
it.skip('it.skip', () => {
5555
console.log('running it.skip');
5656
});

0 commit comments

Comments
 (0)