fix error handling in test saga

Jest used to define fail() but doesn't seem to do this anymore.
Replace it with throwing an error instead, which is basically the
same thing.
This commit is contained in:
David Lechner
2021-01-14 10:50:28 -06:00
parent d7dbaaa12d
commit b6bda26484
+6 -2
View File
@@ -22,7 +22,9 @@ export class AsyncSaga {
channel: this.channel,
dispatch: this.dispatch.bind(this),
getState: () => this.state,
onError: (e) => fail(e),
onError: (e, _i): void => {
throw e;
},
},
saga,
);
@@ -68,7 +70,9 @@ export class AsyncSaga {
this.task.cancel();
await this.task.toPromise();
if (this.dispatches.some((x) => x.type !== END.type)) {
fail(`unhandled dispatches remain: ${JSON.stringify(this.dispatches)}`);
throw Error(
`unhandled dispatches remain: ${JSON.stringify(this.dispatches)}`,
);
}
}