-
Notifications
You must be signed in to change notification settings - Fork 93
Component under test not destroyed between tests #398
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
Hey @lukaleli thanks! Did you by any chance already solve this issue, I want to try to reproduce it but it seems like there's a lot going on in the snippets. |
hi @timdeschryver, thanks for your response. I solved that with workaround (not ideal), because nothing else worked. I'm just clearing head and body in html document in jest setup file in document.body.innerHTML = '';
document.head.innerHTML = ''; I just cannot pinpoint the exact problem why does it happen, because I've used your library before without such issue. |
Thanks for the update @lukaleli , as mentioned that's not ideal. |
I've just faced the same issue and the root cause for me is the fact that my component is removing the Reproduction repo: https://github.com/dzonatan/testing-library-cleanup-repro Maybe OP had something similar in his Temporarily it's possible to fix this by wrapping the component, so the root id doesn't get lost: await render(`<my-comp />`); but this isn't ideal when component has lots of inputs and you want to test them, it becomes very verbose very quickly. Any ideas @timdeschryver if we can somehow fix this from the library side? EDIT: Just found this angular/angular#35215 |
Thanks @dzonatan |
I should be the one thanking for such a quick fix. :D So thanks! |
Hello,
First of all: great library!
I encountered an issue that I have problem solving and probably missing something in the setup. I searched for the solution in issues, tried different options but without success.
Looks like the component I'm testing is rendered twice. First test case works correctly, but the next one actually finds duplicated elements on the screen and looks like it's not teared down between tests.
Here is my test file:
spec.ts
and it fails at the second case with following error:
jest logs
My jest setup:
jest.config.js
I'm running [email protected] on [email protected]. Dependencies versions:
package.json
I honestly have no idea why the mocks are not reset between the tests. I would love to have at least suggestion where the issue may lie. Thanks in advance!
The text was updated successfully, but these errors were encountered: