mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
test: fix flaky timing and timeout guards (#969)
Clears the timeout guards once each race settles, measures the 15,000-vehicle transit ingestion with main-thread CPU time instead of wall time, and times the region-timeout case from the boundary lookup with a 2 s ceiling, below the 3 s default budget, so an ignored budget still fails. Co-authored-by: Sameh Khamis <[email protected]>
This commit is contained in:
1 parent
4cacd4cc00
commit
504d56ba2b
4 files changed
+29
-17
No files matched your search
@@ -357,10 +357,11 @@ test('WebUSB picker remains available when no authorized receiver matches', asyn
|
||||
|
||||
/** Resolve with the promise's value, or 'timed out' after `ms`. */
|
||||
function within(promise, ms = 1_000) {
|
||||
return Promise.race([
|
||||
promise,
|
||||
new Promise((resolve) => setTimeout(() => resolve('timed out'), ms)),
|
||||
]);
|
||||
let timer;
|
||||
const timeout = new Promise((resolve) => {
|
||||
timer = setTimeout(() => resolve('timed out'), ms);
|
||||
});
|
||||
return Promise.race([promise, timeout]).finally(() => clearTimeout(timer));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user