Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix: exit from merge-reports in type: "module" projects (#28725)

Yury Semikhatsky6d583a2dbe86
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);
+});