mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-07-28 04:08:05 +00:00
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:
@@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user