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): escape null control character (#18325)
Max Schmittffc47271f212
diff --git a/packages/playwright-test/src/reporters/junit.ts b/packages/playwright-test/src/reporters/junit.tsindex b8e74ab16d..4dc1076276 100644--- a/packages/playwright-test/src/reporters/junit.ts+++ b/packages/playwright-test/src/reporters/junit.ts@@ -285,7 +285,7 @@ function serializeXML(entry: XMLEntry, tokens: string[], stripANSIControlSequenc}// See https://en.wikipedia.org/wiki/Valid_characters_in_XML-const discouragedXMLCharacters = /[\u0001-\u0008\u000b-\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f]/g;+const discouragedXMLCharacters = /[\u0000-\u0008\u000b-\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f]/g;function escape(text: string, stripANSIControlSequences: boolean, isCharacterData: boolean): string {if (stripANSIControlSequences)diff --git a/tests/playwright-test/reporter-junit.spec.ts b/tests/playwright-test/reporter-junit.spec.tsindex 754661fe67..2116055fb6 100644--- a/tests/playwright-test/reporter-junit.spec.ts+++ b/tests/playwright-test/reporter-junit.spec.ts@@ -106,6 +106,7 @@ test('should render stdout', async ({ runInlineTest }) => {console.log(colors.yellow('Hello world'));console.log('Hello again');console.error('My error');+ console.error('\\0'); // null control charactertest.expect("abc").toBe('abcd');});`,@@ -116,7 +117,8 @@ test('should render stdout', async ({ runInlineTest }) => {expect(testcase['system-out'][0]).toContain('[33mHello world[39m\nHello again');expect(testcase['system-out'][0]).not.toContain('u00');expect(testcase['system-err'][0]).toContain('My error');- expect(testcase['failure'][0]['_']).toContain(`> 11 | test.expect("abc").toBe('abcd');`);+ expect(testcase['system-err'][0]).not.toContain('\u0000'); // null control character+ expect(testcase['failure'][0]['_']).toContain(`> 12 | test.expect("abc").toBe('abcd');`);expect(result.exitCode).toBe(1);});