Skip to content

Commit 25b87ee

Browse files
committed
fix(vitest): call window.close on jsdom teardown
1 parent 2e8909d commit 25b87ee

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/environments/vitest/env/jsdom.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export default <EnvironmentNuxt> async function (global, { jsdom = {} }) {
3939

4040
return {
4141
window,
42-
teardown() {},
42+
teardown() {
43+
window.close()
44+
},
4345
}
4446
}

src/environments/vitest/index.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ export default <Environment>{
3030
}))
3131

3232
if (environmentOptions?.nuxt?.mock?.intersectionObserver) {
33-
win.IntersectionObserver
34-
= win.IntersectionObserver
35-
|| class IntersectionObserver {
36-
observe() {}
37-
unobserve() {}
38-
disconnect() {}
39-
}
33+
win.IntersectionObserver ||= class IntersectionObserver {
34+
observe() {}
35+
unobserve() {}
36+
disconnect() {}
37+
takeRecords() { return [] }
38+
}
4039
}
4140

4241
if (environmentOptions?.nuxt?.mock?.indexedDb) {

0 commit comments

Comments
 (0)