-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
DOM in React snapshot test has changed #1608
Comments
Thank you reporting @EmiBemi! 🙂 I have tried to reproduce this by rendering with react-rest-renderer, and React Testing Library and both worked as expected. What are you using for rendering React in tests? Since v15 of Happy DOM, It would be great if you could provide with some example code of how you run the tests. |
Thanks for the response @capricorn86. I use testing-library/react and vitest. My test looks like this: |
Hi! ran into this in my remix tests. I made a stack blitz that reproduces. https://stackblitz.com/edit/remix-run-remix-o6ajbc?file=test%2F__snapshots__%2FTestComponet.spec.tsx.snap I hope it helps. |
Vitest uses Based on the repro above, this is what I see in https://stackblitz.com/edit/remix-run-remix-ql5k93?file=test%2FTestComponet.spec.tsx const { container } = render(<Stub />);
console.log([
container.constructor,
container.constructor.name,
container.childNodes[0].constructor,
container.childNodes[0].constructor.name,
]);
// [
// [class HTMLDivElement extends HTMLElement],
// 'HTMLDivElement',
// [Function: bound HTMLFormElement],
// 'bound HTMLFormElement'
// ] |
Having this exact problem too! |
This is also impacting a number of our applications and is preventing us upgrading to 15. Occurs for us when using: React 18, React-Testing-Library, Vitest 2 and Happy-DOM 15. |
… form and select elements (#1653)
Thank you for all responses! They really helped when I debugged 🙂 The fix in v16.2.6 should solve the problem. |
Describe the bug
After updating from 15.7.4 to 15.11.0 my React snapshot tests has changed for HTMLSelectElement and HTMLFormElement. The provided screenshot display how it has changed.
Expected behavior
For snapshots I expect the testing DOM to look exactly like the real DOM.
Screenshots
The text was updated successfully, but these errors were encountered: