feat(testrunner): ability to repeat test suites (#681)
Now you can `fdescribe.repeat(10)` to repeat test suites.
This commit is contained in:
parent
541fa95ce4
commit
7128628d70
|
|
@ -322,14 +322,6 @@ class TestRunner extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
// bind methods so that they can be used as a DSL.
|
||||
this.describe = this._addSuite.bind(this, TestMode.Run);
|
||||
this.describe.skip = condition => condition ? this.xdescribe : this.describe;
|
||||
this.fdescribe = this._addSuite.bind(this, TestMode.Focus);
|
||||
this.fdescribe.skip = () => this.fdescribe; // no-op
|
||||
this.xdescribe = this._addSuite.bind(this, TestMode.Skip);
|
||||
this.xdescribe.skip = () => this.xdescribe; // no-op
|
||||
|
||||
const duplicateTest = (amount, mode, timeout) => {
|
||||
return (name, callback) => {
|
||||
for (let i = 0; i < amount; ++i)
|
||||
|
|
@ -337,6 +329,24 @@ class TestRunner extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
const duplicateSuite = (amount, mode) => {
|
||||
return (name, callback, ...args) => {
|
||||
for (let i = 0; i < amount; ++i)
|
||||
this._addSuite(mode, name, callback, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
// bind methods so that they can be used as a DSL.
|
||||
this.describe = this._addSuite.bind(this, TestMode.Run);
|
||||
this.describe.skip = condition => condition ? this.xdescribe : this.describe;
|
||||
this.describe.repeat = number => duplicateSuite(number, TestMode.Run);
|
||||
this.fdescribe = this._addSuite.bind(this, TestMode.Focus);
|
||||
this.fdescribe.skip = () => this.fdescribe; // no-op
|
||||
this.fdescribe.repeat = number => duplicateSuite(number, TestMode.Focus);
|
||||
this.xdescribe = this._addSuite.bind(this, TestMode.Skip);
|
||||
this.xdescribe.skip = () => this.xdescribe; // no-op
|
||||
this.xdescribe.repeat = number => duplicateSuite(number, TestMode.Skip);
|
||||
|
||||
this.it = (name, callback) => void this._addTest(name, callback, TestMode.Run, this._timeout);
|
||||
this.it.skip = condition => condition ? this.xit : this.it;
|
||||
this.it.repeat = number => duplicateTest(number, TestMode.Run, this._timeout);
|
||||
|
|
|
|||
Loading…
Reference in a new issue