chore(testrunner): support first-class test debugging (#1606)
This patch teaches testrunner to override both timeout and parallel execution option if there's attached inspector.
This commit is contained in:
parent
a3a3774926
commit
be438c59c1
@ -9,7 +9,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"unit": "node test/test.js",
|
"unit": "node test/test.js",
|
||||||
"debug-unit": "cross-env DEBUG_TEST=true node --inspect-brk test/test.js",
|
"debug-unit": "node --inspect-brk test/test.js",
|
||||||
"test-doclint": "node utils/doclint/check_public_api/test/test.js && node utils/doclint/preprocessor/test.js",
|
"test-doclint": "node utils/doclint/check_public_api/test/test.js && node utils/doclint/preprocessor/test.js",
|
||||||
"test": "npm run lint --silent && npm run coverage && npm run test-doclint && npm run test-node6-transformer",
|
"test": "npm run lint --silent && npm run coverage && npm run test-doclint && npm run test-node6-transformer",
|
||||||
"install": "node install.js",
|
"install": "node install.js",
|
||||||
|
@ -53,7 +53,7 @@ const defaultBrowserOptions = {
|
|||||||
args: ['--no-sandbox']
|
args: ['--no-sandbox']
|
||||||
};
|
};
|
||||||
|
|
||||||
const timeout = process.env.DEBUG_TEST || slowMo ? 0 : 10 * 1000;
|
const timeout = slowMo ? 0 : 10 * 1000;
|
||||||
let parallel = 1;
|
let parallel = 1;
|
||||||
if (process.env.PPTR_PARALLEL_TESTS)
|
if (process.env.PPTR_PARALLEL_TESTS)
|
||||||
parallel = parseInt(process.env.PPTR_PARALLEL_TESTS.trim(), 10);
|
parallel = parseInt(process.env.PPTR_PARALLEL_TESTS.trim(), 10);
|
||||||
|
@ -21,6 +21,8 @@ const Multimap = require('./Multimap');
|
|||||||
const TimeoutError = new Error('Timeout');
|
const TimeoutError = new Error('Timeout');
|
||||||
const TerminatedError = new Error('Terminated');
|
const TerminatedError = new Error('Terminated');
|
||||||
|
|
||||||
|
const MAJOR_NODEJS_VERSION = parseInt(process.version.substring(1).split('.')[0], 10);
|
||||||
|
|
||||||
class UserCallback {
|
class UserCallback {
|
||||||
constructor(callback, timeout) {
|
constructor(callback, timeout) {
|
||||||
this._callback = callback;
|
this._callback = callback;
|
||||||
@ -269,6 +271,16 @@ class TestRunner extends EventEmitter {
|
|||||||
|
|
||||||
this._hasFocusedTestsOrSuites = false;
|
this._hasFocusedTestsOrSuites = false;
|
||||||
|
|
||||||
|
if (MAJOR_NODEJS_VERSION >= 8) {
|
||||||
|
const inspector = require('inspector');
|
||||||
|
if (inspector.url()) {
|
||||||
|
console.log('TestRunner detected inspector; overriding certain properties to be debugger-friendly');
|
||||||
|
console.log(' - timeout = 0 (Infinite)');
|
||||||
|
this._timeout = 2147483647;
|
||||||
|
this._parallel = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// bind methods so that they can be used as a DSL.
|
// bind methods so that they can be used as a DSL.
|
||||||
this.describe = this._addSuite.bind(this, TestMode.Run);
|
this.describe = this._addSuite.bind(this, TestMode.Run);
|
||||||
this.fdescribe = this._addSuite.bind(this, TestMode.Focus);
|
this.fdescribe = this._addSuite.bind(this, TestMode.Focus);
|
||||||
|
Loading…
Reference in New Issue
Block a user