fix: skip beforeunload handler in test environment
The static cleanup handler was interfering with test lifecycle, causing the server to be killed during database migration. Skip registration when VITEST environment variable is set.
This commit is contained in:
committed by
Mateusz Tymek
parent
427f0d5132
commit
1ee91fcc2f
@@ -78,7 +78,8 @@ export class WindowsProcess implements OpenCodeProcess {
|
||||
}
|
||||
|
||||
// Register beforeunload handler for window close cleanup
|
||||
if (typeof window !== "undefined") {
|
||||
// Skip in test environment to avoid interfering with test lifecycle
|
||||
if (typeof window !== "undefined" && !process.env.VITEST) {
|
||||
window.addEventListener("beforeunload", () => {
|
||||
if (WindowsProcess.currentProcess?.pid) {
|
||||
WindowsProcess.killProcessSync(WindowsProcess.currentProcess.pid);
|
||||
|
||||
Reference in New Issue
Block a user