From 6d583a2dbe867dff6e059b89b860c03588b3f44a Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Tue, 19 Dec 2023 16:49:25 -0800 Subject: [PATCH] fix: exit from merge-reports in type: "module" projects (#28725) Fixes https://github.com/microsoft/playwright/issues/28699 --- packages/playwright/src/cli.ts | 1 + tests/playwright-test/esm.spec.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/playwright/src/cli.ts b/packages/playwright/src/cli.ts index 27328a91bd..1a20424e9a 100644 --- a/packages/playwright/src/cli.ts +++ b/packages/playwright/src/cli.ts @@ -201,6 +201,7 @@ async function mergeReports(reportDir: string | undefined, opts: { [key: string] reporterDescriptions = [[defaultReporter]]; const rootDirOverride = configFile ? config.config.rootDir : undefined; await createMergedReport(config, dir, reporterDescriptions!, rootDirOverride); + gracefullyProcessExitDoNotHang(0); } function overridesFromOptions(options: { [key: string]: any }): ConfigCLIOverrides { diff --git a/tests/playwright-test/esm.spec.ts b/tests/playwright-test/esm.spec.ts index 0a32e35956..a672aff78a 100644 --- a/tests/playwright-test/esm.spec.ts +++ b/tests/playwright-test/esm.spec.ts @@ -672,3 +672,20 @@ test('should be able to use mergeTests/mergeExpect', async ({ runInlineTest }) = expect(result.outputLines).toContain('myFixture1: 1'); expect(result.outputLines).toContain('myFixture2: 2'); }); + +test('should exit after merge-reports', async ({ runInlineTest, mergeReports }) => { + test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/28699' }); + const result = await runInlineTest({ + 'merge.config.ts': ` + export default { reporter: 'line' }; + `, + 'package.json': JSON.stringify({ type: 'module' }), + 'nested/folder/a.esm.test.js': ` + import { test, expect } from '@playwright/test'; + test('test 1', ({}, testInfo) => {}); + ` + }, undefined, undefined, { additionalArgs: ['--reporter', 'blob'] }); + expect(result.exitCode).toBe(0); + const { exitCode } = await mergeReports(test.info().outputPath('blob-report'), undefined, { additionalArgs: ['-c', 'merge.config.ts'] }); + expect(exitCode).toBe(0); +});