mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-25 18:16:32 +00:00
test(tabs): reset activeTabStore before tearing down JSDOM globals
This commit is contained in:
1 parent
399f6d6ce5
commit
dd6713cbad
1 file changed
+10
-1
@@ -37,12 +37,21 @@ async function mountSessionState(t: test.TestContext) {
|
||||
|
||||
t.after(async () => {
|
||||
await act(async () => root.unmount());
|
||||
// Reset activeTabStore while DOM globals are still live and flush any
|
||||
// queued notification before closing JSDOM so notifyRafId is cleared.
|
||||
activeTabStore.setActiveTabId('vault', { recordPrevious: false });
|
||||
await new Promise<void>((resolve) => {
|
||||
if (typeof requestAnimationFrame === 'function') {
|
||||
requestAnimationFrame(() => resolve());
|
||||
} else {
|
||||
dom.window.setTimeout(resolve, 0);
|
||||
}
|
||||
});
|
||||
dom.window.close();
|
||||
for (const [key, descriptor] of previous) {
|
||||
if (descriptor) Object.defineProperty(globalThis, key, descriptor);
|
||||
else Reflect.deleteProperty(globalThis, key);
|
||||
}
|
||||
activeTabStore.setActiveTabId('vault', { recordPrevious: false });
|
||||
});
|
||||
|
||||
return () => latestState;
|
||||
|
||||
Reference in new issue
Block a user