Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Fix timeout handling with `--inspect-brk`/`--inspect`

Juerg Bd4adfa6364df
diff --git a/bin/mocha b/bin/mocha
index 4b0ab8ff..9c634637 100755
--- a/bin/mocha
+++ b/bin/mocha
@@ -54,12 +54,14 @@ const trimV8Option = value =>
Object.keys(opts).forEach(opt => {
if (isNodeFlag(opt)) {
nodeArgs[trimV8Option(opt)] = opts[opt];
- disableTimeouts(opt);
} else {
mochaArgs[opt] = opts[opt];
}
});
+// disable 'timeout' for debugFlags
+Object.keys(nodeArgs).forEach(opt => disableTimeouts(opt));
+
// Native debugger handling
// see https://nodejs.org/api/debugger.html#debugger_debugger
// look for 'inspect' or 'debug' that would launch this debugger,
diff --git a/test/integration/fixtures/options/slow-test.fixture.js b/test/integration/fixtures/options/slow-test.fixture.js
index f15cb6d9..952e6567 100644
--- a/test/integration/fixtures/options/slow-test.fixture.js
+++ b/test/integration/fixtures/options/slow-test.fixture.js
@@ -5,7 +5,7 @@ describe('a suite', function() {
setTimeout(done, 500);
});
- it('should succeed in 1.5s', function(done) {
- setTimeout(done, 1500);
+ it('should succeed in 1.1s', function(done) {
+ setTimeout(done, 1100);
});
});
diff --git a/test/integration/options/timeout.spec.js b/test/integration/options/timeout.spec.js
index ac786da5..4470c8b3 100644
--- a/test/integration/options/timeout.spec.js
+++ b/test/integration/options/timeout.spec.js
@@ -49,4 +49,19 @@ describe('--timeout', function() {
done();
});
});
+
+ it('should disable timeout with --inspect', function(done) {
+ var fixture = 'options/slow-test';
+ runMochaJSON(fixture, ['--inspect', '--timeout', '200'], function(
+ err,
+ res
+ ) {
+ if (err) {
+ done(err);
+ return;
+ }
+ expect(res, 'to have passed').and('to have passed test count', 2);
+ done();
+ });
+ });
});