feat(testrunner): support --repeat CLI flag to repeat tests (#1828)
This allows you to run `npm run cunit -- --repeat 10` to run tests multiple times.
This commit is contained in:
parent
d0b8710670
commit
51b8685a8c
|
|
@ -197,6 +197,13 @@ function collect(browserNames) {
|
||||||
testRunner.focusMatchingTests(new RegExp(filter, 'i'));
|
testRunner.focusMatchingTests(new RegExp(filter, 'i'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const repeatArgIndex = process.argv.indexOf('--repeat');
|
||||||
|
if (repeatArgIndex !== -1) {
|
||||||
|
const repeat = parseInt(process.argv[repeatArgIndex + 1], 10);
|
||||||
|
if (!isNaN(repeat))
|
||||||
|
testRunner.repeatAll(repeat);
|
||||||
|
}
|
||||||
|
|
||||||
return testRunner;
|
return testRunner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,7 @@ class TestCollector {
|
||||||
this._api = {};
|
this._api = {};
|
||||||
|
|
||||||
this._currentSuite = new Suite(null, '', new Location());
|
this._currentSuite = new Suite(null, '', new Location());
|
||||||
|
this._rootSuite = this._currentSuite;
|
||||||
|
|
||||||
this._api.describe = specBuilder(this._suiteModifiers, this._suiteAttributes, (specs, name, suiteCallback, ...suiteArgs) => {
|
this._api.describe = specBuilder(this._suiteModifiers, this._suiteAttributes, (specs, name, suiteCallback, ...suiteArgs) => {
|
||||||
const location = Location.getCallerLocation();
|
const location = Location.getCallerLocation();
|
||||||
|
|
@ -223,6 +224,10 @@ class TestCollector {
|
||||||
suites() {
|
suites() {
|
||||||
return this._suites;
|
return this._suites;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rootSuite() {
|
||||||
|
return this._rootSuite;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { TestCollector, specBuilder, FocusedFilter, Repeater };
|
module.exports = { TestCollector, specBuilder, FocusedFilter, Repeater };
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,10 @@ class DefaultTestRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repeatAll(repeatCount) {
|
||||||
|
this._repeater.repeat(this._collector.rootSuite(), repeatCount);
|
||||||
|
}
|
||||||
|
|
||||||
async run() {
|
async run() {
|
||||||
let reporter = null;
|
let reporter = null;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue