qunitx-cli 0.21.2 → 0.22.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.
Files changed (3) hide show
  1. package/README.md +80 -15
  2. package/dist/cli.js +787 -678
  3. package/package.json +6 -3
package/README.md CHANGED
@@ -14,8 +14,9 @@ output to the terminal.
14
14
 
15
15
  ## Features
16
16
 
17
- - Runs `.js` and `.ts` test files in headless Chrome, Firefox, or WebKit (Playwright + esbuild)
18
- - TypeScript works with zero configuration — esbuild handles transpilation
17
+ - Runs `.js`, `.ts`, `.jsx`, and `.tsx` test files in headless Chrome, Firefox, or WebKit (Playwright + esbuild)
18
+ - TypeScript and JSX work with zero configuration — esbuild handles transpilation, including the React 17+ automatic JSX runtime
19
+ - Bring your own esbuild plugins through `package.json` for `.vue`, `.svelte`, and other custom loaders
19
20
  - Inline source maps for accurate stack traces pointing to original source files
20
21
  - Streams TAP-formatted output to the terminal in real time
21
22
  - Concurrent mode (default) splits test files across all CPU cores for fast parallel runs
@@ -165,29 +166,93 @@ All CLI flags can also be set in `package.json` under the `qunitx` key, so you d
165
166
  "qunitx": {
166
167
  "inputs": ["test/**/*-test.js", "test/**/*-test.ts"],
167
168
  "htmlPaths": ["test/tests.html"],
168
- "extensions": ["js", "ts"],
169
+ "extensions": ["js", "ts", "jsx", "tsx"],
169
170
  "output": "tmp",
170
171
  "timeout": 20000,
171
172
  "failFast": false,
172
173
  "port": 1234,
173
- "browser": "chromium"
174
+ "browser": "chromium",
175
+ "plugins": []
174
176
  }
175
177
  }
176
178
  ```
177
179
 
178
- | Key | Default | Description |
179
- | ------------ | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
180
- | `inputs` | `[]` | Glob patterns, file paths, or directories to use as test entry points. Merged with any paths given on the CLI. |
181
- | `htmlPaths` | `[]` | Optional HTML templates to run tests inside. Any listed `.html` file that contains `{{qunitxScript}}` or other handlebars-style tokens is treated as a test runner template. |
182
- | `extensions` | `["js", "ts"]` | File extensions tracked for test discovery (directory scans) and watch-mode rebuild triggers. Add `"mjs"`, `"cjs"`, or any other extension your project uses. |
183
- | `output` | `"tmp"` | Directory where compiled test bundles are written. |
184
- | `timeout` | `20000` | Maximum milliseconds to wait for the full test suite before timing out. |
185
- | `failFast` | `false` | Stop the run after the first failing test. |
186
- | `port` | `1234` | Preferred HTTP server port. qunitx auto-selects a free port if this one is taken. |
187
- | `browser` | `"chromium"` | Browser engine to use: `"chromium"`, `"firefox"`, or `"webkit"`. Overridden by `--browser` on the CLI. |
180
+ | Key | Default | Description |
181
+ | ------------ | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
182
+ | `inputs` | `[]` | Glob patterns, file paths, or directories to use as test entry points. Merged with any paths given on the CLI. |
183
+ | `htmlPaths` | `[]` | Optional HTML templates to run tests inside. Any listed `.html` file that contains `{{qunitxScript}}` or other handlebars-style tokens is treated as a test runner template. |
184
+ | `extensions` | `["js", "ts", "jsx", "tsx"]` | File extensions tracked for test discovery (directory scans) and watch-mode rebuild triggers. Add `"mjs"`, `"cjs"`, or any other extension your project uses. |
185
+ | `output` | `"tmp"` | Directory where compiled test bundles are written. |
186
+ | `timeout` | `20000` | Maximum milliseconds to wait for the full test suite before timing out. |
187
+ | `failFast` | `false` | Stop the run after the first failing test. |
188
+ | `port` | `1234` | Preferred HTTP server port. qunitx auto-selects a free port if this one is taken. |
189
+ | `browser` | `"chromium"` | Browser engine to use: `"chromium"`, `"firefox"`, or `"webkit"`. Overridden by `--browser` on the CLI. |
190
+ | `plugins` | `[]` | esbuild plugin specifiers loaded from your `node_modules` and applied to the test bundle. See [esbuild plugins](#esbuild-plugins). |
188
191
 
189
192
  CLI flags always override `package.json` values when both are present.
190
193
 
194
+ ## JSX / TSX
195
+
196
+ `.jsx` and `.tsx` files are picked up automatically — no configuration needed. The bundle uses esbuild's automatic JSX runtime so React 17+ "no `import React`" code just works:
197
+
198
+ ```tsx
199
+ // test/button-test.tsx
200
+ import { module, test } from 'qunitx';
201
+ import { flushSync } from 'react-dom';
202
+ import { createRoot } from 'react-dom/client';
203
+ import { Button } from '../src/button.tsx';
204
+
205
+ module('Button', (hooks) => {
206
+ let container;
207
+ hooks.beforeEach(() => {
208
+ container = document.createElement('div');
209
+ document.body.appendChild(container);
210
+ });
211
+ hooks.afterEach(() => container.remove());
212
+
213
+ test('renders the label', (assert) => {
214
+ flushSync(() => createRoot(container).render(<Button label="Save" />));
215
+ assert.equal(container.querySelector('button').textContent, 'Save');
216
+ });
217
+ });
218
+ ```
219
+
220
+ Vue, Preact, Solid, and other JSX dialects work via a one-line override at the top of each file:
221
+
222
+ ```tsx
223
+ /** @jsxImportSource vue */
224
+ import { createApp } from 'vue';
225
+ // ...JSX uses vue/jsx-runtime instead of react/jsx-runtime
226
+ ```
227
+
228
+ You can also set `compilerOptions.jsxImportSource` in your `tsconfig.json` to apply the override across a directory.
229
+
230
+ ## esbuild plugins
231
+
232
+ For file formats esbuild does not handle natively (e.g. `.vue` SFCs, `.svelte`), declare plugin specifiers in `package.json#qunitx.plugins`. qunitx dynamic-imports each one from your project's `node_modules` and passes it to the build:
233
+
234
+ ```json
235
+ {
236
+ "qunitx": {
237
+ "extensions": ["js", "ts", "jsx", "tsx", "vue"],
238
+ "plugins": [
239
+ "esbuild-plugin-vue-next",
240
+ ["esbuild-svelte", { "compilerOptions": { "css": "injected" } }]
241
+ ]
242
+ }
243
+ }
244
+ ```
245
+
246
+ Each entry is one of:
247
+
248
+ | Form | Behavior |
249
+ | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
250
+ | `"<package-name>"` | Imports the package. If the default export is a function, it's called with no arguments to produce the plugin; otherwise the export is used as the plugin. |
251
+ | `["<package-name>", <options>]` | Same, but the factory is called with `<options>` as its only argument. Use this form to pass plugin-specific configuration. |
252
+ | `"./relative/plugin.js"` | Loads a plugin you wrote yourself. Resolved against the project root (where your `package.json` lives). |
253
+
254
+ Don't forget to add the plugin's file extension(s) to `qunitx.extensions` so directory scans and watch-mode rebuilds pick them up.
255
+
191
256
  ### Environment variables
192
257
 
193
258
  | Variable | Description |
@@ -218,7 +283,7 @@ Options:
218
283
  --debug Print the server URL; pipe browser console to stdout
219
284
  --timeout=<ms> Max ms to wait for the suite to finish [default: 20000]
220
285
  --output=<dir> Directory for compiled test assets [default: ./tmp]
221
- --extensions=<...> Comma-separated file extensions to track [default: js,ts]
286
+ --extensions=<...> Comma-separated file extensions to track [default: js,ts,jsx,tsx]
222
287
  --before=<file> Script to run (and optionally await) before tests start
223
288
  --after=<file> Script to run (and optionally await) after tests finish
224
289
  --open, -o Open output in the test browser as soon as the bundle is ready