Skip to content

[Bug]: codegen writes \\${ in multiline toMatchAriaSnapshot, so the generated test throws #43459

Closed

Description

@nancy6547

Version

main (ac22e99)

Steps to reproduce

  1. Run npx playwright codegen on a page with <ul><li>Cost ${price}</li><li>Pay</li></ul>
  2. Pick "Assert snapshot" and select the list.

Expected behavior

The generated JavaScript keeps ${price} as literal text: - listitem: Cost \${price}

Actual behavior

await expect(page.locator('ul')).toMatchAriaSnapshot(`
  - list:
    - listitem: Cost \\${price}
    - listitem: Pay
  `);

\\ is a literal backslash, so ${price} is interpolated and the test fails with ReferenceError: price is not defined. Single-line snapshots are fine.

Additional context

quoteMultiline in packages/isomorphic/codegen/javascript.ts escapes ${ inside escape() and then again on each line of multiline text. Removing the second replace fixes it. I have the fix with a unit test ready and would be happy to open a PR.

Activity

  1. nancy6547 commented on Oct 16, 2026

    @nancy6547
    Author

    Thanks for the quick fix in #43472! Closing since it’s merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions