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(codegen): do not escape ${ twice in multiline template literals (#43472)
Yury Semikhatskybf58017f2f16
diff --git a/packages/isomorphic/codegen/javascript.ts b/packages/isomorphic/codegen/javascript.tsindex ca0fcb9f61..36b6accb8f 100644--- a/packages/isomorphic/codegen/javascript.ts+++ b/packages/isomorphic/codegen/javascript.ts@@ -280,7 +280,7 @@ export function quoteMultiline(text: string, indent = ' ') {const lines = text.split('\n');if (lines.length === 1)return '`' + escape(text) + '`';- return '`\n' + lines.map(line => indent + escape(line).replace(/\${/g, '\\${')).join('\n') + `\n${indent}\``;+ return '`\n' + lines.map(line => indent + escape(line)).join('\n') + `\n${indent}\``;}function isMultilineString(text: string) {diff --git a/tests/library/inspector/cli-codegen-aria.spec.ts b/tests/library/inspector/cli-codegen-aria.spec.tsindex 3c8d3cce7d..c54cd5b3a4 100644--- a/tests/library/inspector/cli-codegen-aria.spec.ts+++ b/tests/library/inspector/cli-codegen-aria.spec.ts@@ -152,10 +152,12 @@ test.describe(() => {await expect(recorder.recorderPage.locator('.source-line-error-underline')).toHaveCount(1);});- test('should generate valid javascript with multiline snapshot assertion', async ({ openRecorder }) => {+ test('should generate valid javascript with multiline snapshot assertion', {+ annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/43459' },+ }, async ({ openRecorder }) => {const { recorder } = await openRecorder();// set width and height to 100% to ensure click is outside of the list- await recorder.setContentAndWait(`<body style="width:100%;height:100%"><ul><li>item 1</li><li>item 2</li></ul></body>`);+ await recorder.setContentAndWait(`<body style="width:100%;height:100%"><ul><li>item 1</li><li>Cost \${price}</li></ul></body>`);await recorder.page.click('x-pw-tool-item.snapshot');await recorder.page.hover('body');@@ -167,7 +169,7 @@ test.describe(() => {` await expect(page.locator('body')).toMatchAriaSnapshot(\``,` - list:`,` - listitem: item 1`,- ` - listitem: item 2`,+ ` - listitem: "Cost \\\${price}"`,` \`);`,].join('\n'));@@ -177,7 +179,7 @@ test.describe(() => {` // await expect(page.locator('body')).toMatchAriaSnapshot(\``,` // - list:`,` // - listitem: item 1`,- ` // - listitem: item 2`,+ ` // - listitem: "Cost \\\${price}"`,` // \`);`,].join('\n'));