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

Tests with jsdom/react don't seem to exit #140

Closed
DavidWells opened this issue Sep 28, 2021 · 4 comments
Closed

Tests with jsdom/react don't seem to exit #140

DavidWells opened this issue Sep 28, 2021 · 4 comments

Comments

@DavidWells
Copy link

DavidWells commented Sep 28, 2021

Trying to use uvu + @testing-library/react for some fast tests 😃

However, it seems that uvu never exits once the tests are complete.

image

Here is a repro repo: https://github.com/DavidWells/uvu-jsdom-error-repro

If I comment out the component test https://github.com/DavidWells/uvu-jsdom-error-repro/blob/master/src/__tests__/index.js#L10-L27 uvu returns as expected.

Any ideas on how to fix this?

Thanks for the great lib as always ❤️


Running this in node v16.6.1 if that helps

@DavidWells
Copy link
Author

Found another repro https://github.com/tommywalkie/uvu-jsdom-node-16-repro/tree/c5005cd6520ba27a334836bb862ba4307e719455 linked to #124 (comment)

The suggested fix works

test.after(() => {
  setTimeout(() => {
    process.exit(0)
  }, 500)
}) 

@lukeed
Copy link
Owner

lukeed commented Sep 28, 2021

See #91 and #124 for related items. This means something isn't exiting itself (likely your jsdom hook) and uvu waits for everything to close before it exits.. since that's part of the testing responsibility.

If you look at the included svelte/Preact examples, there's a setup and teardown helper called for each suite, which is controlling the jsdom lifecycle to make sure it's not lingering.

@DavidWells
Copy link
Author

In this case, it looks like the cause is the render function from @testing-library/react

@ChristopherMeek
Copy link

@DavidWells Did you ever get to the bottom of the issue in @testing-library/react?

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

3 participants