reactjs - redux-saga-test-plan 中 testSaga 和 ExpectSaga 的区别

标签 reactjs redux redux-saga redux-saga-test-plan

expectSaga 用于集成测试而 testSaga 用于一般断言是否正确?

实际上,我实际上可以在所有测试中互换使用它们,所以我对何时使用哪个感到有点困惑。

最佳答案

我认为单元测试 [1] 下的自述文件中的副标题行是关于何时使用 testSagaexpectSaga 的最简洁的解释:

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/

相关文章:

reactjs - 运行弹出的项目抛出 "Expo sdk required expo to run"

reactjs - React useEffect 包括缺少的依赖项会破坏它

javascript - 为什么我不能在 Redux-Saga 的 for..in 循环中使用嵌套 yield

javascript - Redux saga 事件 channel 在执行另一个 saga 后终止

javascript - 我们可以将 race 与 takeEvery 一起使用吗?

javascript - 有什么方法可以在暗模式切换时更改 tailwind css 中的图像?

javascript - React - componentDidUpdate 无限次调用

javascript - 从 Angular-Redux 商店获取最新状态

angular - Ngxs - 调用 Angular 服务 : good practices?

redux-saga - 在普通函数/事件 channel 中使用选择效果