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:
@@ -64,7 +64,18 @@ async function settle() {
|
||||
for (let i = 0; i < 50; i++) await Promise.resolve();
|
||||
}
|
||||
|
||||
// While an approval is pending, the background starts a 20-second timer to
|
||||
// keep itself running. The timer is stubbed and never starts, so no test in
|
||||
// this file leaves it running.
|
||||
let keepRunningTimer;
|
||||
beforeEach(() => {
|
||||
keepRunningTimer = jest
|
||||
.spyOn(global, "setInterval")
|
||||
.mockImplementation(() => 1);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
keepRunningTimer.mockRestore();
|
||||
delete global.chrome;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user