svelte-testing-library
svelte-testing-library copied to clipboard
Snapshot testing is breaking
Bug Report
Describe the bug
I get stuck when run a simple snapshot test with my component - it has not any prop.
![Captura de Tela 2020-11-24 às 19 12 06](https://user-images.githubusercontent.com/4103305/100157227-f376a100-2e88-11eb-98e2-174cad8ab919.png)
Expected behavior
Pass the test and generate a snapshot file.
Environment
Node: v12.18.2 OS: macOS Catalina 10.15.7
Additional context/Screenshots
My component
My test file
This has to do with Svelte. A way around this would be to utilize a serializing function that converts DOM elements (and their children) into JSON in order to properly compare.
Edit: This is very specific to snapshot testing. The same is done for every other frontend library to my knowledge.
Recommend looking at this for reference: https://gist.github.com/sstur/7379870
@benmonro Want me to add a couple helper functions based on the above to aide in proper DOM snapshot testing?
Sure
On Sat, Dec 26, 2020 at 9:37 AM Bob [email protected] wrote:
@benmonro https://github.com/benmonro Want me to add a couple helper functions based on the above to aide in proper DOM snapshot testing?
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/testing-library/svelte-testing-library/issues/103#issuecomment-751378315, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADBPBHYZQSBN6ULQJ6RH5TSWYNOZANCNFSM4UBPCSBA .
-- Ben Monro Software Developer
I'll go ahead and close this issue, as we have tests in the repo that use toMatchSnapshot()
(https://github.com/testing-library/svelte-testing-library/blob/main/src/tests/render.test.js#L73)