Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@web/test-runner] Tests do not finish when asserting frozen objects #2728

Closed
lucaelin opened this issue May 10, 2024 · 0 comments · Fixed by #2731
Closed

[@web/test-runner] Tests do not finish when asserting frozen objects #2728

lucaelin opened this issue May 10, 2024 · 0 comments · Fixed by #2731

Comments

@lucaelin
Copy link
Contributor

When asserting frozen objects in WTR, the test-file never finishes according to the cli.
Here is a test-case:

import { expect } from '@open-wc/testing';

describe('readonly', () => {
  it('gets stuck when throwing readonly array of objects', () => {
    const obj = [
			{}
		];
    const frozenObj = Object.freeze(obj);
    expect(frozenObj).to.be.empty;
  });
})

When running this test in puppeteer or playwright, the test never finshes. When inspecting the test-browsers devtools, you can see the following error message:
image

The error seems to originate in a websocket handler, that tries to stringify the error message while skipping circular structures. The stringified object is then send to the wtr-cli for printing. But the decircularization and stringification failes in this case, because the target error message is not mutable.

I've uploaded a working repro of this bug in this repo:
https://github.com/lucaelin/wtr-readonly-error-bug

A possible solution is also included in the repository, by first running structuredClone on the input prior to stringification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant