test: add timeout to saga take

This will crash tests sooner and give a stack track at the crash point
instead of waiting the default 5 seconds for the entire test to timeout
(which doesn't give a stack trace of where the test was when it timed
out).
This commit is contained in:
David Lechner
2022-03-28 11:48:08 -05:00
parent 07a03d4ea7
commit 110d93860a
+3
View File
@@ -51,11 +51,14 @@ export class AsyncSaga {
// if there are no dispatches queued, then queue the taker to be
// completed later
return new Promise((resolve, reject) => {
const timeout = setTimeout(reject, 500, new Error('timed out'));
this.takers.push({
put: (a: AnyAction): void => {
if (a.type === END.type) {
reject();
} else {
clearTimeout(timeout);
resolve(a);
}
},