Skip to content

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

fix(test-runner): make test.slow() idempotent (#39596)

Pavel Feldmane36906c334ae
diff --git a/packages/playwright/src/worker/timeoutManager.ts b/packages/playwright/src/worker/timeoutManager.ts
index c003342d15..5d930f5338 100644
--- a/packages/playwright/src/worker/timeoutManager.ts
+++ b/packages/playwright/src/worker/timeoutManager.ts
@@ -56,6 +56,7 @@ export class TimeoutManager {
private _defaultSlot: TimeSlot;
private _running?: Running;
private _ignoreTimeouts = false;
+ private _slow = false;
constructor(timeout: number) {
this._defaultSlot = { timeout, elapsed: 0 };
@@ -136,6 +137,9 @@ export class TimeoutManager {
}
slow() {
+ if (this._slow)
+ return;
+ this._slow = true;
const slot = this._running ? this._running.slot : this._defaultSlot;
slot.timeout = slot.timeout * 3;
if (this._running)
diff --git a/tests/playwright-test/test-modifiers.spec.ts b/tests/playwright-test/test-modifiers.spec.ts
index e73e483b27..8e985bd069 100644
--- a/tests/playwright-test/test-modifiers.spec.ts
+++ b/tests/playwright-test/test-modifiers.spec.ts
@@ -756,3 +756,18 @@ test('should skip beforeEach hooks upon modifiers', async ({ runInlineTest }) =>
expect(result.passed).toBe(1);
expect(result.skipped).toBe(1);
});
+
+test('test.slow should be idempotent', async ({ runInlineTest }) => {
+ const result = await runInlineTest({
+ 'a.test.ts': `
+ import { test, expect } from '@playwright/test';
+ test('slow test', async ({}) => {
+ test.slow();
+ test.slow();
+ expect(test.info().timeout).toBe(90000);
+ });
+ `,
+ });
+ expect(result.exitCode).toBe(0);
+ expect(result.passed).toBe(1);
+});