我想测试我的传奇我能够测试单个传奇电话,但我如何使用jest测试我的观察者传奇
export default function* saga() {
yield [
takeLatest(dataTypeActions.ACTION1, fetchDataType),
takeLatest(sourceActions.ACTION2, fetchFromSource),
takeLatest(targetActions.ACTION3, fetchFromTarget),
];
}
某些正文将帮助我如何使用jest(uisng生成器函数)测试并行调用
答案 0 :(得分:1)
你可以这样测试:
it('watches several actions...', () => {
const generator = yourSaga();
expect(generator.next().value).toEqual([
takeLatest(dataTypeActions.ACTION1, fetchDataType),
takeLatest(sourceActions.ACTION2, fetchFromSource),
takeLatest(targetActions.ACTION3, fetchFromTarget),
]);
});