test: the test suite exits on its own, without --forceExit (closes #585)
Some tests left timers running when they ended, and --forceExit hid them; both test scripts drop it. Six background test files left the background's 20-second timer running while an approval was pending; each now stubs it for the whole file. Five popup test files left a flash message's two-second timer running; they now use fake timers, and a wait on real zero-delay timeouts became jest.advanceTimersByTimeAsync(0). Two ethers timers can still run for up to 250 ms after a test ends; they stop before jest checks for open handles. Model: opus-5-5
This commit was merged in pull request #710.
This commit is contained in:
@@ -131,10 +131,14 @@ async function review(amount, token) {
|
||||
async function confirm(amount, token) {
|
||||
const txInfo = await review("0.5", token);
|
||||
confirmTx.show({ ...txInfo, amount });
|
||||
for (let i = 0; i < 10; i++) await new Promise((r) => setTimeout(r, 0));
|
||||
for (let i = 0; i < 10; i++) await jest.advanceTimersByTimeAsync(0);
|
||||
}
|
||||
|
||||
// showFlash() starts a timer that clears the message two seconds later. Each
|
||||
// test here runs on fake timers and drops them in afterEach, so that timer
|
||||
// never outlives the test.
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers();
|
||||
elements.clear();
|
||||
state.wallets = [
|
||||
{
|
||||
@@ -167,6 +171,10 @@ beforeEach(() => {
|
||||
state.currentView = null;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
describe.each([
|
||||
["1e-3", "ETH"],
|
||||
["1e-3", "TOK"],
|
||||
|
||||
Reference in New Issue
Block a user