-
Notifications
You must be signed in to change notification settings - Fork 33
Unable to test a non-bound change in the DOM #119
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
Comments
I have similar problem when testing button clicks that will change the DOM. Sometimes it works, sometimes it doesn't. |
I'm nearly sure i'm running into the same issue. It doesn't seem to re-render the dom after a click event. |
I'm experiencing the same symptoms when testing a modal component. An initial test interaction triggers a change in the component (the menu content goes from hidden to rendered); but a subsequent interaction in the same test - that should close the menu - fails to update the 'rendered' output (e.g. as seen in debug()) and the test fails. Inspecting the property that controls visibility shows it has updated 😕 edit: in my case it appears that the problem is the use of a transition in the tested component. See #206 |
Takes care of the lack of reactivity seen in #119
It seems that using |
Takes care of the lack of reactivity seen in #119
The cause of this, specifically, is that jsdom does not support
@yanick I think this ticket should be considered outside the scope of svelte-testing-library closed. I don't think switching our tests to happy-dom is the right move at this time (see my comment in #286 for reasoning) |
Agreed. And having the tests run both under jsdom and happy-dom strikes me as better than flopping around. But that's a talk for #286 :-) |
I am new to testing-library, so I hope I'm not missing anything obvious.
I have a helper class whose methods make changes in a component's DOM, some upon interaction by the user. I am unable to test those changes with
fireEvent
oruserEvent
. It always fails.I simplified my use case to a very simple example:
expect(info).toHaveTextContent("Modified by click")
fails but, curiously enough, aconsole.log(paragraph.innerText)
shows the change.Code for the component:
The code for the test.
Is this a bug of the library or should I be approaching this test differently?
P.S.: I asked on Discord, both in the testing-library and the svelte communities. I've also researched the documentation and previous issues. While I'm not entirely sure this is a bug, I would very much appreciate an indication of where to seek a solution if the fault resides in my approach.
The text was updated successfully, but these errors were encountered: