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(video): serialize test overlay updates (#42896)
Yury Semikhatskyec31a7bf7ef0
diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.tsindex d7860be83c..ddd84a685b 100644--- a/packages/playwright/src/index.ts+++ b/packages/playwright/src/index.ts@@ -881,7 +881,7 @@ async function installScreencastTitleUpdater(testInfo: TestInfoImpl, context: Brconst fontSize = testAnnotate.fontSize ?? 14;const level = testAnnotate.level ?? 'step';- const updateOverlay = async () => {+ const doUpdateOverlay = async () => {const parts = level === 'step' ? [...testTitle, ...stepStack] : testTitle;const html = createTestOverlay(parts, position, fontSize);for (const page of context.pages()) {@@ -891,6 +891,12 @@ async function installScreencastTitleUpdater(testInfo: TestInfoImpl, context: Broverlays.set(page, disposable);}};+ let lastUpdate = Promise.resolve();+ const updateOverlay = () => {+ const result = lastUpdate.then(doUpdateOverlay);+ lastUpdate = result.catch(() => {});+ return result;+ };testInfo._onUserStepBegin = async title => {stepStack.push(title);await updateOverlay();diff --git a/tests/playwright-test/playwright.spec.ts b/tests/playwright-test/playwright.spec.tsindex 853f7ed7ae..33ac3988af 100644--- a/tests/playwright-test/playwright.spec.ts+++ b/tests/playwright-test/playwright.spec.ts@@ -618,6 +618,26 @@ test('should work with video: retain-on-first-failure', async ({ runInlineTest }expect(fs.readdirSync(dirRetry).find(file => file.endsWith('webm'))).toBeFalsy();});+test('should show a single test overlay when a step starts right after page creation', async ({ runInlineTest }) => {+ const result = await runInlineTest({+ 'playwright.config.ts': `+ module.exports = { use: { video: { mode: 'on', show: { test: { level: 'step' } } } }, name: 'chromium' };+ `,+ 'a.test.ts': `+ import { test, expect } from '@playwright/test';+ test('my test', async ({ page }) => {+ await test.step('first step', async () => {+ const lines = await page.locator('.x-pw-user-overlay').evaluateAll(els => els.map(el => el.innerText.split('\\n')));+ expect(lines).toEqual([['a.test.ts', 'my test', 'first step']]);+ });+ });+ `,+ }, { workers: 1 });++ expect(result.exitCode).toBe(0);+ expect(result.passed).toBe(1);+});+test('should work with video: retain-on-failure-and-retries', async ({ runInlineTest }) => {const result = await runInlineTest({'playwright.config.ts': `