说 expectSaga
用于集成测试而 testSaga
用于一般断言是否正确?
实际上,我实际上可以在所有测试中互换使用它们,所以我对何时使用哪个感到有点困惑。
最佳答案
我认为单元测试 [1] 下的自述文件中的副标题行是关于何时使用 testSaga
与 expectSaga
的最简洁的解释:
If you want to ensure that your saga yields specific types of effects in a particular order, then you can use the testSaga function.
如果您不关心这种级别的细节,尤其是排序位,那么 expectSaga
就不那么严格,因此对您的传奇中 future 的更改不会那么脆弱。但在某些情况下,您需要非常具体地了解哪些效果按哪个顺序,在这种情况下您应该使用 testSaga
。
[1] https://github.com/jfairbank/redux-saga-test-plan#unit-testing
关于reactjs - redux-saga-test-plan 中 testSaga 和 ExpectSaga 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57965795/