Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(expect): clone `pollIntervals` so they are not consumed across calls (#41480)
Devin Rousso9cef3e510ce8
diff --git a/packages/isomorphic/timeoutRunner.ts b/packages/isomorphic/timeoutRunner.tsindex b001c6bc03..4ffe5d86ae 100644--- a/packages/isomorphic/timeoutRunner.ts+++ b/packages/isomorphic/timeoutRunner.ts@@ -39,7 +39,7 @@ export async function raceAgainstDeadline<T>(cb: () => Promise<T>, deadline: num});}-export async function pollAgainstDeadline<T>(callback: () => Promise<{ continuePolling: boolean, result: T }>, deadline: number, pollIntervals: number[] = [100, 250, 500, 1000]): Promise<{ result?: T, timedOut: boolean }> {+export async function pollAgainstDeadline<T>(callback: () => Promise<{ continuePolling: boolean, result: T }>, deadline: number, [...pollIntervals]: number[] = [100, 250, 500, 1000]): Promise<{ result?: T, timedOut: boolean }> {const lastPollInterval = pollIntervals.pop() ?? 1000;let lastResult: T|undefined;const wrappedCallback = () => Promise.resolve().then(callback);diff --git a/tests/playwright-test/expect-to-pass.spec.ts b/tests/playwright-test/expect-to-pass.spec.tsindex c3d16639db..f5e4072c29 100644--- a/tests/playwright-test/expect-to-pass.spec.ts+++ b/tests/playwright-test/expect-to-pass.spec.ts@@ -114,6 +114,27 @@ test('should respect interval', async ({ runInlineTest }) => {expect(result.exitCode).toBe(0);});+test('should not consume the shared toPass intervals across tests', async ({ runInlineTest }) => {+ const result = await runInlineTest({+ 'playwright.config.ts': `+ module.exports = { expect: { toPass: { intervals: [0, 0, 0] } } };+ `,+ 'a.spec.ts': `+ import { test, expect } from '@playwright/test';+ for (const name of ['one', 'two']) {+ test(name, async () => {+ let probes = 0;+ await test.expect(() => {+ ++probes;+ expect(probes).toBeGreaterThanOrEqual(3);+ }).toPass({ timeout: 1000 });+ });+ }+ `+ }, { workers: 1 });+ expect(result.passed).toBe(2);+});+test('should compile', async ({ runTSC }) => {const result = await runTSC({'a.spec.ts': `