Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(junit): Replace spread operator with for-of loop to prevent RangeError with large console logs (#37767)
Copilotfd84e37a66e4
diff --git a/packages/playwright/src/reporters/junit.ts b/packages/playwright/src/reporters/junit.tsindex a5304da77a..96f4288615 100644--- a/packages/playwright/src/reporters/junit.ts+++ b/packages/playwright/src/reporters/junit.ts@@ -193,8 +193,10 @@ class JUnitReporter implements ReporterV2 {const systemOut: string[] = [];const systemErr: string[] = [];for (const result of test.results) {- systemOut.push(...result.stdout.map(item => item.toString()));- systemErr.push(...result.stderr.map(item => item.toString()));+ for (const item of result.stdout)+ systemOut.push(item.toString());+ for (const item of result.stderr)+ systemErr.push(item.toString());for (const attachment of result.attachments) {if (!attachment.path)continue;diff --git a/tests/playwright-test/reporter-junit.spec.ts b/tests/playwright-test/reporter-junit.spec.tsindex 9947484903..838f35e841 100644--- a/tests/playwright-test/reporter-junit.spec.ts+++ b/tests/playwright-test/reporter-junit.spec.ts@@ -126,6 +126,28 @@ for (const useIntermediateMergeReport of [false, true] as const) {expect(result.exitCode).toBe(1);});+ test('should handle large number of console logs', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/37719' } }, async ({ runInlineTest }, testInfo) => {+ test.slow();+ // need to go via disk, otherwise our test harness would print 500k lines of stdout to the Github Actions UI that can't handle it.+ const reportFile = testInfo.outputPath('report.xml');+ const result = await runInlineTest({+ 'a.test.ts': `+ import { test, expect } from '@playwright/test';+ test('one', async ({}) => {+ test.slow();+ for (let i = 0; i < 500000; i++) {+ console.log('log line ' + i);+ }+ });+ `,+ }, { reporter: 'junit' }, { PLAYWRIGHT_JUNIT_OUTPUT_FILE: reportFile });+ expect(result.exitCode).toBe(0);+ const report = await fs.promises.readFile(reportFile, 'utf8');+ const testcase = parseXML(report)['testsuites']['testsuite'][0]['testcase'][0];+ expect(testcase['system-out']).toHaveLength(1);+ expect(testcase['system-out'][0]).toContain('log line 99999');+ });+test('should render stdout without ansi escapes', async ({ runInlineTest }) => {const result = await runInlineTest({'playwright.config.ts': `