Skip to content

[BUG] evaluate serializing fails at 1.38 #27181

@Tallyb

Description

@Tallyb

[This is a closable issue, as I could not provide a failing repro. Nevertheless, I know the PW team is really good at solving my issues even when they are somewhat vague]

System info

  • Playwright Version: [v1.38]
  • Operating System: [All, Windows 11, Ubuntu 20, macOS 13.2, etc.]
  • Browser: [Chromium]
  • Other info:

Source code

We are using component.evaluate on an angular storybook to test UI components.
We use a fixture that does

  getComponent: async ({}, use) => {
    async function getComponentHelper(component: Locator): Promise<any> {
      await component.waitFor({ state: 'attached' });
      const ngCmp = await component.evaluate((c) => {
        const comp = window['ng'].getComponent(c);
        return comp;
      });
      return ngCmp;
    }
    await use(getComponentHelper);
  },

ng.getComponent is an angular browser method that returns the angular object from a DOM element.

In version 1.37 we could easily do that on any component.
Starting 1.38 the component is returned to the node context as undefined.
I managed to try and pin it down on the browser for our private repo.

Selecting an angular element in the elements console:

console.log (window.ng.getComponent($0)) -> works

Json.stringify(window.ng.getComponent($0)) -> VM3387:1 Uncaught TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Window'
--- property 'window' closes the circle
at JSON.stringify ()
at :1:6

I could not reproduce a failing object on a repro, however it seems like PW (or upstream browser?) is less forgiving when trying to serializing objects on evaluate.

  • I provided exact source code that allows reproducing the issue locally.

Link to the GitHub repository with the repro

https://github.com/Tallyb/angular-realworld-example-app
npx ng run ang2-conduit:storybook
run test in: src/app/article/article-component.component.test.ts

Steps

  • [Run the test]
  • [...]

Expected

[Describe expected behavior]

Actual

[Describe actual behavior]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions