@noma.to/qwik-testing-library 1.5.1 → 1.5.2
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 +14 -6
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -290,7 +290,7 @@ Here's an example on how to use the `mock$` function:
|
|
|
290
290
|
// import qwik-testing methods
|
|
291
291
|
import {render, screen, waitFor} from "@noma.to/qwik-testing-library";
|
|
292
292
|
// import qwik-mock methods
|
|
293
|
-
import {mock
|
|
293
|
+
import {clearAllMocks, mock$} from "@noma.to/qwik-mock";
|
|
294
294
|
// import the userEvent methods to interact with the DOM
|
|
295
295
|
import {userEvent} from "@testing-library/user-event";
|
|
296
296
|
|
|
@@ -300,9 +300,7 @@ import {Counter} from "./counter";
|
|
|
300
300
|
// describe the test suite
|
|
301
301
|
describe("<Counter />", () => {
|
|
302
302
|
// initialize a mock
|
|
303
|
-
|
|
304
|
-
const onChangeMock = mock$(() => {
|
|
305
|
-
});
|
|
303
|
+
const onChangeMock = mock$();
|
|
306
304
|
|
|
307
305
|
// setup beforeEach block to run before each test
|
|
308
306
|
beforeEach(() => {
|
|
@@ -325,15 +323,25 @@ describe("<Counter />", () => {
|
|
|
325
323
|
await user.click(decrementBtn);
|
|
326
324
|
|
|
327
325
|
// assert that the onChange$ callback was called with the right value
|
|
328
|
-
// note: QRLs are async in Qwik, so we need to resolve them to verify interactions
|
|
329
326
|
await waitFor(() =>
|
|
330
|
-
expect(onChangeMock
|
|
327
|
+
expect(onChangeMock).toHaveBeenCalledWith(-1),
|
|
331
328
|
);
|
|
332
329
|
});
|
|
333
330
|
});
|
|
334
331
|
})
|
|
335
332
|
```
|
|
336
333
|
|
|
334
|
+
You can also provide a default implementation to `mock$`:
|
|
335
|
+
|
|
336
|
+
```tsx
|
|
337
|
+
const onSubmitMock = mock$(() => "success");
|
|
338
|
+
|
|
339
|
+
await render(<SubmitForm onSubmit$={onSubmitMock} />);
|
|
340
|
+
await user.click(screen.getByRole("button", { name: "Submit" }));
|
|
341
|
+
|
|
342
|
+
expect(await screen.findByText("success")).toBeInTheDocument();
|
|
343
|
+
```
|
|
344
|
+
|
|
337
345
|
### Qwik City - `server$` calls
|
|
338
346
|
|
|
339
347
|
If one of your Qwik components uses `server$` calls, your tests might fail with a rather cryptic message (e.g. `QWIK
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noma.to/qwik-testing-library",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Simple and complete Qwik testing utilities that encourage good testing practices.",
|
|
5
5
|
"repository": "https://github.com/ianlet/qwik-testing-library",
|
|
6
6
|
"homepage": "https://github.com/ianlet/qwik-testing-library",
|
|
@@ -40,16 +40,16 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/eslint": "8.56.10",
|
|
43
|
-
"@types/node": "25.
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
45
|
-
"@typescript-eslint/parser": "8.
|
|
43
|
+
"@types/node": "25.3.3",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "8.56.1",
|
|
45
|
+
"@typescript-eslint/parser": "8.56.1",
|
|
46
46
|
"eslint": "8.57.1",
|
|
47
47
|
"eslint-plugin-qwik": "1.19.0",
|
|
48
48
|
"prettier": "3.8.1",
|
|
49
49
|
"typescript": "5.9.3",
|
|
50
50
|
"undici": "*",
|
|
51
51
|
"vite": "7.3.1",
|
|
52
|
-
"vite-tsconfig-paths": "^6.
|
|
52
|
+
"vite-tsconfig-paths": "^6.1.1",
|
|
53
53
|
"vitest": "^4.0.18"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|