From 8bd62ae29ff5ec89dd4ff0b7c8107c4f7f375c2f Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 23 Feb 2024 19:58:18 -0600 Subject: [PATCH] test: add test for on-first-failure mode --- .../playwright.artifacts.spec.ts | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/playwright-test/playwright.artifacts.spec.ts b/tests/playwright-test/playwright.artifacts.spec.ts index 5a54d8f981..561f58ed5a 100644 --- a/tests/playwright-test/playwright.artifacts.spec.ts +++ b/tests/playwright-test/playwright.artifacts.spec.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import { test, expect } from './playwright-test-fixtures'; import fs from 'fs'; import path from 'path'; +import { expect, test } from './playwright-test-fixtures'; function listFiles(dir: string): string[] { const result: string[] = []; @@ -338,6 +338,31 @@ test('should work with trace: on-all-retries', async ({ runInlineTest }, testInf ]); }); +test('should work with trace: on-first-failure', async ({ runInlineTest }, testInfo) => { + const result = await runInlineTest({ + ...testFiles, + 'playwright.config.ts': ` + module.exports = { use: { trace: 'on-first-failure' } }; + `, + }, { workers: 1, retries: 2 }); + + expect(result.exitCode).toBe(1); + expect(result.passed).toBe(5); + expect(result.failed).toBe(5); + expect(listFiles(testInfo.outputPath('test-results'))).toEqual([ + 'artifacts-failing', + ' trace.zip', + 'artifacts-own-context-failing', + ' trace.zip', + 'artifacts-persistent-failing', + ' trace.zip', + 'artifacts-shared-shared-failing', + ' trace.zip', + 'artifacts-two-contexts-failing', + ' trace.zip', + ]); +}); + test('should take screenshot when page is closed in afterEach', async ({ runInlineTest }, testInfo) => { const result = await runInlineTest({ 'playwright.config.ts': `