vitest-browser-qwik 0.0.3 → 0.0.4
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/README.md
CHANGED
|
@@ -52,17 +52,21 @@ test('renders counter with SSR', async () => {
|
|
|
52
52
|
### Hook Testing Example
|
|
53
53
|
|
|
54
54
|
```tsx
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
55
|
+
import { useSignal } from "@builder.io/qwik";
|
|
56
|
+
import { expect, test } from "vitest";
|
|
57
|
+
import { renderHook } from "vitest-browser-qwik";
|
|
58
|
+
import { useCounter } from "./fixtures/useCounter";
|
|
57
59
|
|
|
58
|
-
test(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
test("should increment counter", async () => {
|
|
61
|
+
const { result } = await renderHook(() =>
|
|
62
|
+
useCounter({ countSignal: useSignal(0) }),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
console.log("RESULT", result);
|
|
66
|
+
|
|
67
|
+
await result.increment$();
|
|
68
|
+
|
|
69
|
+
expect(result.count.value).toBe(1);
|
|
66
70
|
});
|
|
67
71
|
```
|
|
68
72
|
|
|
@@ -73,7 +77,7 @@ Both `render` and `renderSSR` provide the same testing interface, but work diffe
|
|
|
73
77
|
- **`render` (CSR)**: Renders components in the browser context
|
|
74
78
|
- **`renderSSR` (SSR)**: Executes components in a Node.js context to generate server-side HTML, then provides that HTML for testing
|
|
75
79
|
|
|
76
|
-
The SSR approach is unique because it executes your components in a different context than your test files,
|
|
80
|
+
The SSR approach is unique because it executes your components in a different context than your test files, real server-side rendering behavior in Vitest.
|
|
77
81
|
|
|
78
82
|
## Render Options
|
|
79
83
|
|
|
@@ -109,6 +113,12 @@ test('renders with custom container', async () => {
|
|
|
109
113
|
- **SSR Context**: `renderSSR` executes components in a Node.js context separate from your test files, providing true server-side rendering simulation
|
|
110
114
|
- **Same Interface**: Both CSR and SSR provide the same testing interface, making it easy to test both rendering modes
|
|
111
115
|
|
|
116
|
+
## Limitations
|
|
117
|
+
|
|
118
|
+
- For `renderSSR` you must always import the component from another file, local components are not supported. This is because this would require importing the vitest context, or moving local components into separate files dynamically, which involves a lot of unwanted complexity.
|
|
119
|
+
|
|
120
|
+
- In the vitest config there is a hardcoded value for whether or not browser mode is headless. This is because when relying on environment variables, it seems there is an additional cost in the vitest core side that introduces potential race conditions.
|
|
121
|
+
|
|
112
122
|
## Contributing
|
|
113
123
|
|
|
114
124
|
Feel free to open issues and pull requests. All contributions are welcome!
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all) __defProp(target, name, {
|
|
13
|
+
get: all[name],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
19
|
+
key = keys[i];
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
21
|
+
get: ((k) => from[k]).bind(null, key),
|
|
22
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { __commonJS, __export, __toESM };
|