Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

feat(testrunner): add `it.repeat` to repeat test multiple times (#568)

Andrey Lushnikov710554bff568
diff --git a/utils/testrunner/TestRunner.js b/utils/testrunner/TestRunner.js
index 78530e1061..8f0dc1838d 100644
--- a/utils/testrunner/TestRunner.js
+++ b/utils/testrunner/TestRunner.js
@@ -330,12 +330,22 @@ class TestRunner extends EventEmitter {
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)
+ this._addTest(name, callback, mode, timeout);
+ }
+ }
+
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);
this.fit = (name, callback) => void this._addTest(name, callback, TestMode.Focus, this._timeout);
this.fit.skip = () => this.fit; // no-op
+ this.fit.repeat = number => duplicateTest(number, TestMode.Focus, this._timeout);
this.xit = (name, callback) => void this._addTest(name, callback, TestMode.Skip, this._timeout);
this.xit.skip = () => this.xit; // no-op
+ this.xit.repeat = number => duplicateTest(number, TestMode.Skip, this._timeout);
this._debuggerLogBreakpointLines = new Multimap();
this.dit = (name, callback) => {