I'm trying to test a component that uses a custom hook. That hook uses context with the useContext
hook. My problem is that the context persists between two consecutive tests. I've tried mocking the context, but that doesn't help.
You can see the code in this codesandbox: https://codesandbox.io/s/l0192w68z though I couldn't get the tests to run there...
I also uploaded it to github where the tests actually run: https://github.com/uriklar/react-testing-library-with-use-context
I'd appreciate any pointers! How can I get a fresh context on every test run.
Thanks!
Aucun commentaire:
Enregistrer un commentaire