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

prettyDom returns incorrect html for form with happy-dom #1344

Open
gkiely opened this issue Dec 16, 2024 · 1 comment
Open

prettyDom returns incorrect html for form with happy-dom #1344

gkiely opened this issue Dec 16, 2024 · 1 comment

Comments

@gkiely
Copy link

gkiely commented Dec 16, 2024

  • @testing-library/dom version: 6.6.3
  • Testing Framework and version: vitest (or any other)
  • DOM Environment: happy-dom

Relevant code or config:

https://github.com/gkiely/vite-project/blob/main/src/App.test.tsx

Reproduction:

1. git clone https://github.com/gkiely/vite-project
2. npm i
3. Update package.json: "test": "vitest --environment happy-dom"
4. npm test # incorrect output for happy-dom

Problem description:

Makes it difficult to debug issues

@gkiely
Copy link
Author

gkiely commented Dec 16, 2024

For reference, using:

render(
  <form role="form">
    <div>test</div>
    <input type="text" />
    <button type="submit">submit</button>
  </form>
);

Input:

const form = screen.getByRole('form');
screen.debug(Array.from(form.children));

Output:

<div>
  test
</div>
<input
  type="text"
/>
<button
  type="submit"
>
  submit
</button>

Input:

const form = screen.getByRole('form');
screen.debug(form);

Output:

bound HTMLFormElement {
  "0": <input
    type="text"
  />,
  "1": <button
    type="submit"
  >
    submit
  </button>,
}

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

No branches or pull requests

1 participant