From b6bda26484304db19bb84527348c8bbec0d7beed Mon Sep 17 00:00:00 2001 From: David Lechner Date: Thu, 14 Jan 2021 10:50:28 -0600 Subject: [PATCH] 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. --- test/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/index.ts b/test/index.ts index 3f0e1685..5e54bb9c 100644 --- a/test/index.ts +++ b/test/index.ts @@ -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)}`, + ); } }