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

Isolating global states between tests #396

Open
xereda opened this issue Jul 11, 2023 · 4 comments
Open

Isolating global states between tests #396

xereda opened this issue Jul 11, 2023 · 4 comments
Labels
question Further information is requested

Comments

@xereda
Copy link

xereda commented Jul 11, 2023

Isolating global states between tests

I use the Testing Library to implement unit and integration tests. I have components sharing global states maintained by Hookstate. What is the correct way to write tests for these components and not have problems when the tests are run in parallel?

Thanks in advance for any support.

@avkonst
Copy link
Owner

avkonst commented Jul 11, 2023

parallel tests should run in separate worker threads, each having its own copy of the runtime and ram state... at least it is the case with jest and playwright... what test framework do you use?

@avkonst avkonst added the question Further information is requested label Jul 11, 2023
@xereda
Copy link
Author

xereda commented Jul 12, 2023

next.js + jest + testing library

@avkonst
Copy link
Owner

avkonst commented Jul 12, 2023

so, jest runs tests in parallel by default in isolated worker threads... please make sure it is the case

@xereda
Copy link
Author

xereda commented Jul 13, 2023

@avkonst

That's right! I ended up getting confused by the concept. The context, window and any global states are not shared between tests, right?

I believe it has nothing to do with Hookstate.

Even so, thanks for your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants