admin管理员组文章数量:1400837
currently I have the following situation with my React App using Zustand that I am testing with Vitest:
I have a parent controller component A and a child of that controller component B that both use a shared Zustand store S. I've written some tests for A with Vitest and React Testing Library, where I am mocking the child component B and using the actual store S (and resetting it between each test, ie each 'it' statement). However, if I were to create another describe block within the same file to test component B, how would I be able to do this if B has been mocked in the file? Since from what I understand mocks are hoisted in Vitest. Furthermore, if I put the tests for B in another file, from what I understand different Vitest files run in parallel, thus there could be an error due to them both accessing store S.
Does anyone know how best to resolve this? Thank you!
本文标签: reactjsTesting My React App with Zustand (or any state manager) QuestionStack Overflow
版权声明:本文标题:reactjs - Testing My React App with Zustand (or any state manager) Question - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744273506a2598298.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论