From ceaa29cec1d19fb04e55eb828fff720e2c035079 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Mon, 5 Jun 2023 17:20:54 -0700 Subject: [PATCH] chore: clear message for no reports (#23492) --- packages/playwright-test/src/reporters/merge.ts | 2 ++ tests/playwright-test/reporter-blob.spec.ts | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/packages/playwright-test/src/reporters/merge.ts b/packages/playwright-test/src/reporters/merge.ts index a7041e9849..f67b4fd243 100644 --- a/packages/playwright-test/src/reporters/merge.ts +++ b/packages/playwright-test/src/reporters/merge.ts @@ -26,6 +26,8 @@ import { Multiplexer } from './multiplexer'; export async function createMergedReport(config: FullConfigInternal, dir: string, reporterDescriptions: ReporterDescription[], resolvePaths: boolean) { const shardFiles = await sortedShardFiles(dir); + if (shardFiles.length === 0) + throw new Error(`No report files found in ${dir}`); const events = await mergeEvents(dir, shardFiles); if (resolvePaths) patchAttachmentPaths(events, dir); diff --git a/tests/playwright-test/reporter-blob.spec.ts b/tests/playwright-test/reporter-blob.spec.ts index 5c1aa0404a..14fb3d00b5 100644 --- a/tests/playwright-test/reporter-blob.spec.ts +++ b/tests/playwright-test/reporter-blob.spec.ts @@ -965,3 +965,11 @@ test('same project different suffixes', async ({ runInlineTest, mergeReports }) expect(exitCode).toBe(0); expect(output).toContain(`projects: [ 'foo-first', 'foo-second' ]`); }); + +test('no reports error', async ({ runInlineTest, mergeReports }) => { + const reportDir = test.info().outputPath('blob-report'); + fs.mkdirSync(reportDir, { recursive: true }); + const { exitCode, output } = await mergeReports(reportDir); + expect(exitCode).toBe(1); + expect(output).toContain(`No report files found in`); +});