From 8eedbda4a2ea586834fd6b957f91c28e55137e2a Mon Sep 17 00:00:00 2001 From: Devin Rousso Date: Wed, 16 Sep 2026 11:13:12 -0600 Subject: [PATCH] feat(config): show only failures in CI terminal output generated projects currently print progress for successful tests on CI add `list` with `printOnlyFailures` on CI while preserving the HTML report --- assets/playwright-ct.config.js | 2 +- assets/playwright-ct.config.ts | 2 +- assets/playwright.config.js | 2 +- assets/playwright.config.ts | 2 +- tests/integration.spec.ts | 19 +++++++++++++++++++ 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/assets/playwright-ct.config.js b/assets/playwright-ct.config.js index 881142e..f6fd510 100644 --- a/assets/playwright-ct.config.js +++ b/assets/playwright-ct.config.js @@ -17,7 +17,7 @@ module.exports = defineConfig({ /* Retry on CI only */ retries: process.env.CI ? 2 : 0, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: 'html', + reporter: process.env.CI ? [['list', { printOnlyFailures: true }], ['html']] : 'html', /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ diff --git a/assets/playwright-ct.config.ts b/assets/playwright-ct.config.ts index b89cefa..d6d5757 100644 --- a/assets/playwright-ct.config.ts +++ b/assets/playwright-ct.config.ts @@ -16,7 +16,7 @@ export default defineConfig({ /* Retry on CI only */ retries: process.env.CI ? 2 : 0, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: 'html', + reporter: process.env.CI ? [['list', { printOnlyFailures: true }], ['html']] : 'html', /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ diff --git a/assets/playwright.config.js b/assets/playwright.config.js index 3e2be33..89ac209 100644 --- a/assets/playwright.config.js +++ b/assets/playwright.config.js @@ -21,7 +21,7 @@ export default defineConfig({ /* Retry on CI only */ retries: process.env.CI ? 2 : 0, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: 'html', + reporter: process.env.CI ? [['list', { printOnlyFailures: true }], ['html']] : 'html', /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('')`. */ diff --git a/assets/playwright.config.ts b/assets/playwright.config.ts index 1977879..b0f8eb3 100644 --- a/assets/playwright.config.ts +++ b/assets/playwright.config.ts @@ -20,7 +20,7 @@ export default defineConfig({ /* Retry on CI only */ retries: process.env.CI ? 2 : 0, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: 'html', + reporter: process.env.CI ? [['list', { printOnlyFailures: true }], ['html']] : 'html', /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('')`. */ diff --git a/tests/integration.spec.ts b/tests/integration.spec.ts index ff0843d..9783371 100644 --- a/tests/integration.spec.ts +++ b/tests/integration.spec.ts @@ -27,6 +27,25 @@ const validGitignore = [ '/playwright/.auth/' ].join('\n'); +for (const language of ['TypeScript', 'JavaScript'] as const) { + for (const componentTesting of [false, true]) { + test(`should configure failures-only CI reporting for ${language} ${componentTesting ? 'component' : 'end-to-end'} tests`, async ({ run, dir }) => { + await run(componentTesting ? ['--ct'] : [], { + language, + testDir: 'tests', + installGitHubActions: false, + installPlaywrightDependencies: false, + installPlaywrightBrowsers: false, + framework: componentTesting ? 'react' : undefined, + }); + const extension = language === 'TypeScript' ? 'ts' : 'js'; + const file = componentTesting ? `playwright-ct.config.${extension}` : `playwright.config.${extension}`; + const config = fs.readFileSync(path.join(dir, file), 'utf8'); + expect(config).toContain("reporter: process.env.CI ? [['list', { printOnlyFailures: true }], ['html']] : 'html',"); + }); + } +} + test('should generate a project in the current directory', async ({ run, dir, packageManager }) => { test.skip(packageManager === 'yarn-classic' || packageManager === 'yarn-berry'); test.slow();