@noma.to/qwik-testing-library 1.4.0 → 1.5.0

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
@@ -131,7 +131,7 @@ should be installed as one of your project's `devDependencies`:
131
131
  npm install --save-dev @noma.to/qwik-testing-library @testing-library/dom
132
132
  ```
133
133
 
134
- This library supports `qwik` versions `1.7.2` and above and `@testing-library/dom` versions `10.1.0` and above.
134
+ This library supports `qwik` versions `1.12.0` and above and `@testing-library/dom` versions `10.1.0` and above.
135
135
 
136
136
  You may also be interested in installing `@testing-library/jest-dom` and `@testing-library/user-event` so you can
137
137
  use [the custom jest matchers][jest-dom] and [the user event library][user-event] to test interactions with the DOM.
@@ -162,10 +162,10 @@ npm install --save-dev happy-dom
162
162
  We recommend using `@noma.to/qwik-testing-library` with [Vitest][vitest] as your test
163
163
  runner.
164
164
 
165
- If you haven't done so already, add vitest to your project using Qwik CLI:
165
+ If you haven't done so already, install vitest:
166
166
 
167
167
  ```shell
168
- npm run qwik add vitest
168
+ npm install --save-dev vitest
169
169
  ```
170
170
 
171
171
  After that, we need to configure Vitest so it can run your tests.
@@ -195,7 +195,10 @@ export default defineConfig((configEnv) =>
195
195
  // configure your test environment
196
196
  test: {
197
197
  environment: "jsdom", // or "happy-dom"
198
- setupFiles: ["./vitest.setup.ts"],
198
+ setupFiles: [
199
+ "@noma.to/qwik-testing-library/setup",
200
+ "@testing-library/jest-dom/vitest", // optional, for DOM matchers
201
+ ],
199
202
  globals: true,
200
203
  },
201
204
  }),
@@ -218,24 +221,8 @@ As the build will try to use `./src/index.ts` as the entry point, we need to cre
218
221
  */
219
222
  ```
220
223
 
221
- Then, create the `vitest.setup.ts` file:
222
-
223
- ```ts
224
- // vitest.setup.ts
225
-
226
- // Configure DOM matchers to work in Vitest
227
- import "@testing-library/jest-dom/vitest";
228
-
229
- // This has to run before qdev.ts loads. `beforeAll` is too late
230
- globalThis.qTest = false; // Forces Qwik to run as if it was in a Browser
231
- globalThis.qRuntimeQrl = true;
232
- globalThis.qDev = true;
233
- globalThis.qInspector = false;
234
- ```
235
-
236
- This setup will make sure that Qwik is properly configured.
237
- It also loads `@testing-library/jest-dom/vitest` in your test runner
238
- so you can use matchers like `expect(...).toBeInTheDocument()`.
224
+ The `@noma.to/qwik-testing-library/setup` module configures Qwik globals (`qTest`, `qRuntimeQrl`, `qDev`,
225
+ `qInspector`) for testing. It must run before any Qwik code loads, which is why it's added to `setupFiles`.
239
226
 
240
227
  By default, Qwik Testing Library cleans everything up automatically for you.
241
228
  You can opt out of this by setting the environment variable `QTL_SKIP_AUTO_CLEANUP` to `true`.
@@ -309,7 +296,7 @@ describe("<Counter />", () => {
309
296
  await user.click(incrementBtn);
310
297
 
311
298
  // assert that the counter is now 2
312
- await waitFor(() => expect(screen.findByText(/count:2/)).toBeInTheDocument());
299
+ expect(await screen.findByText(/count:2/)).toBeInTheDocument();
313
300
  });
314
301
  })
315
302
  ```
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ globalThis.qTest = false;
4
+ globalThis.qRuntimeQrl = true;
5
+ globalThis.qDev = true;
6
+ globalThis.qInspector = false;
7
+ const __qwikSetupComplete = true;
8
+ exports.__qwikSetupComplete = __qwikSetupComplete;
@@ -0,0 +1,8 @@
1
+ globalThis.qTest = false;
2
+ globalThis.qRuntimeQrl = true;
3
+ globalThis.qDev = true;
4
+ globalThis.qInspector = false;
5
+ const __qwikSetupComplete = true;
6
+ export {
7
+ __qwikSetupComplete
8
+ };
@@ -1,4 +1,4 @@
1
- import { JSXOutput } from "@builder.io/qwik";
1
+ import type { JSXOutput } from "@builder.io/qwik";
2
2
  import type { Options, Result } from "./types";
3
3
  declare function render(ui: JSXOutput, options?: Options): Promise<Result>;
4
4
  declare function cleanup(): void;
@@ -0,0 +1,7 @@
1
+ declare global {
2
+ var qTest: boolean;
3
+ var qRuntimeQrl: boolean;
4
+ var qDev: boolean;
5
+ var qInspector: boolean;
6
+ }
7
+ export declare const __qwikSetupComplete = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noma.to/qwik-testing-library",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
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",
@@ -13,6 +13,11 @@
13
13
  "types": "./lib-types/index.d.ts",
14
14
  "import": "./lib/index.qwik.mjs",
15
15
  "require": "./lib/index.qwik.cjs"
16
+ },
17
+ "./setup": {
18
+ "types": "./lib-types/setup.d.ts",
19
+ "import": "./lib/setup.qwik.mjs",
20
+ "require": "./lib/setup.qwik.cjs"
16
21
  }
17
22
  },
18
23
  "files": [
@@ -35,17 +40,17 @@
35
40
  },
36
41
  "devDependencies": {
37
42
  "@types/eslint": "8.56.10",
38
- "@types/node": "24.5.0",
39
- "@typescript-eslint/eslint-plugin": "8.44.0",
40
- "@typescript-eslint/parser": "8.45.0",
43
+ "@types/node": "25.1.0",
44
+ "@typescript-eslint/eslint-plugin": "8.54.0",
45
+ "@typescript-eslint/parser": "8.54.0",
41
46
  "eslint": "8.57.1",
42
- "eslint-plugin-qwik": "1.16.0",
43
- "prettier": "3.6.2",
44
- "typescript": "5.9.2",
47
+ "eslint-plugin-qwik": "1.19.0",
48
+ "prettier": "3.8.1",
49
+ "typescript": "5.9.3",
45
50
  "undici": "*",
46
- "vite": "7.1.7",
47
- "vite-tsconfig-paths": "^5.1.4",
48
- "vitest": "^3.2.4"
51
+ "vite": "7.3.1",
52
+ "vite-tsconfig-paths": "^6.0.5",
53
+ "vitest": "^4.0.18"
49
54
  },
50
55
  "peerDependencies": {
51
56
  "@builder.io/qwik": ">= 1.12.0 < 2",