vitest-browser-qwik 0.3.6 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as renderServerHTML, n as render, r as renderHook, t as cleanup } from "./pure-
|
|
2
|
-
import { beforeEach } from "vitest";
|
|
1
|
+
import { i as renderServerHTML, n as render, r as renderHook, t as cleanup } from "./pure-Wh9CgMND.js";
|
|
2
|
+
import { afterEach, beforeEach } from "vitest";
|
|
3
3
|
import { page } from "vitest/browser";
|
|
4
4
|
|
|
5
5
|
//#region src/index.ts
|
|
@@ -18,6 +18,9 @@ page.extend({
|
|
|
18
18
|
beforeEach(async () => {
|
|
19
19
|
await cleanup();
|
|
20
20
|
});
|
|
21
|
+
afterEach(async () => {
|
|
22
|
+
await cleanup();
|
|
23
|
+
});
|
|
21
24
|
|
|
22
25
|
//#endregion
|
|
23
26
|
export { cleanup, render, renderHook, renderSSR, renderServerHTML };
|
|
@@ -7,6 +7,11 @@ import { jsx } from "@qwik.dev/core/jsx-runtime";
|
|
|
7
7
|
const { debug, getElementLocatorSelectors } = utils;
|
|
8
8
|
const mountedContainers = /* @__PURE__ */ new Set();
|
|
9
9
|
let qwikLoaderInjected = false;
|
|
10
|
+
function destroyContainer(container) {
|
|
11
|
+
container.innerHTML = "";
|
|
12
|
+
mountedContainers.delete(container);
|
|
13
|
+
if (container.parentNode === document.body) document.body.removeChild(container);
|
|
14
|
+
}
|
|
10
15
|
function csrQwikLoader() {
|
|
11
16
|
if (qwikLoaderInjected) return;
|
|
12
17
|
const script = document.createElement("script");
|
|
@@ -17,9 +22,7 @@ function csrQwikLoader() {
|
|
|
17
22
|
function createRenderResult(container, baseElement) {
|
|
18
23
|
mountedContainers.add(container);
|
|
19
24
|
const unmount = () => {
|
|
20
|
-
container
|
|
21
|
-
mountedContainers.delete(container);
|
|
22
|
-
if (container.parentNode === document.body) document.body.removeChild(container);
|
|
25
|
+
destroyContainer(container);
|
|
23
26
|
};
|
|
24
27
|
return {
|
|
25
28
|
container,
|
|
@@ -83,10 +86,8 @@ async function renderHook(hook) {
|
|
|
83
86
|
}
|
|
84
87
|
async function cleanup() {
|
|
85
88
|
mountedContainers.forEach((container) => {
|
|
86
|
-
container
|
|
87
|
-
if (container.parentNode === document.body) document.body.removeChild(container);
|
|
89
|
+
destroyContainer(container);
|
|
88
90
|
});
|
|
89
|
-
mountedContainers.clear();
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
//#endregion
|
package/dist/pure.js
CHANGED