hookstate icon indicating copy to clipboard operation
hookstate copied to clipboard

Isolating global states between tests

Open xereda opened this issue 2 years ago • 4 comments

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.

xereda avatar Jul 11 '23 18:07 xereda

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 avatar Jul 11 '23 20:07 avkonst

next.js + jest + testing library

xereda avatar Jul 12 '23 20:07 xereda

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

avkonst avatar Jul 12 '23 22:07 avkonst

@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.

xereda avatar Jul 13 '23 13:07 xereda