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(test runner): do not write missing snapshot until the last retry (#9246)
Dmitry Gozman5e3ad63b42bd
diff --git a/src/test/matchers/toMatchSnapshot.ts b/src/test/matchers/toMatchSnapshot.tsindex c987b032a0..f1d9b7b600 100644--- a/src/test/matchers/toMatchSnapshot.ts+++ b/src/test/matchers/toMatchSnapshot.ts@@ -46,7 +46,7 @@ export function toMatchSnapshot(this: ReturnType<Expect['getState']>, received:options.name,testInfo.snapshotPath,testInfo.outputPath,- testInfo.config.updateSnapshots,+ testInfo.retry < testInfo.project.retries ? 'none' : testInfo.config.updateSnapshots,withNegateComparison,options);diff --git a/tests/playwright-test/golden.spec.ts b/tests/playwright-test/golden.spec.tsindex b997e9359d..c3cd866a70 100644--- a/tests/playwright-test/golden.spec.ts+++ b/tests/playwright-test/golden.spec.ts@@ -562,3 +562,24 @@ test('should attach expected/actual and no diff', async ({ runInlineTest }, test]);});+test('should fail with missing expectations and retries', async ({ runInlineTest }, testInfo) => {+ const result = await runInlineTest({+ ...files,+ 'playwright.config.ts': `+ module.exports = { retries: 1 };+ `,+ 'a.spec.js': `+ const { test } = require('./helper');+ test('is a test', ({}) => {+ expect('Hello world').toMatchSnapshot('snapshot.txt');+ });+ `+ });++ expect(result.exitCode).toBe(1);+ expect(result.failed).toBe(1);+ const snapshotOutputPath = testInfo.outputPath('a.spec.js-snapshots/snapshot.txt');+ expect(result.output).toContain(`${snapshotOutputPath} is missing in snapshots, writing actual`);+ const data = fs.readFileSync(snapshotOutputPath);+ expect(data.toString()).toBe('Hello world');+});