Skip to content

Commit d4adfa6

Browse files
authored
Fix timeout handling with --inspect-brk/--inspect
1 parent aab8555 commit d4adfa6

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

bin/mocha

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ const trimV8Option = value =>
5454
Object.keys(opts).forEach(opt => {
5555
if (isNodeFlag(opt)) {
5656
nodeArgs[trimV8Option(opt)] = opts[opt];
57-
disableTimeouts(opt);
5857
} else {
5958
mochaArgs[opt] = opts[opt];
6059
}
6160
});
6261

62+
// disable 'timeout' for debugFlags
63+
Object.keys(nodeArgs).forEach(opt => disableTimeouts(opt));
64+
6365
// Native debugger handling
6466
// see https://nodejs.org/api/debugger.html#debugger_debugger
6567
// look for 'inspect' or 'debug' that would launch this debugger,

test/integration/fixtures/options/slow-test.fixture.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('a suite', function() {
55
setTimeout(done, 500);
66
});
77

8-
it('should succeed in 1.5s', function(done) {
9-
setTimeout(done, 1500);
8+
it('should succeed in 1.1s', function(done) {
9+
setTimeout(done, 1100);
1010
});
1111
});

test/integration/options/timeout.spec.js

+15
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,19 @@ describe('--timeout', function() {
4949
done();
5050
});
5151
});
52+
53+
it('should disable timeout with --inspect', function(done) {
54+
var fixture = 'options/slow-test';
55+
runMochaJSON(fixture, ['--inspect', '--timeout', '200'], function(
56+
err,
57+
res
58+
) {
59+
if (err) {
60+
done(err);
61+
return;
62+
}
63+
expect(res, 'to have passed').and('to have passed test count', 2);
64+
done();
65+
});
66+
});
5267
});

0 commit comments

Comments
 (0)