You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit da09cd3
Browse filesBrowse the repository at this point in the historyBrowse files
Allow runners to filter configured WPT cases before test registration. Provide a Vitest integration and a Router-based `wpt` command that accepts literal search text, so focused runs omit unrelated cases instead of reporting them as skipped.
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,15 +15,18 @@ You need the exact Node and pnpm versions listed under `devEngines` in the root
15
15
16
16
Any version manager works. If you use [mise](https://mise.jdx.dev), which is what our lint, format, and test checks use, export `MISE_IDIOMATIC_VERSION_FILE_ENABLE_TOOLS=node,pnpm` and run `mise install` so it reads those versions from `package.json`.
17
17
18
-
Then install the dependencies:
18
+
Then install the dependencies and build the packages:
19
19
20
20
```sh
21
21
pnpm install
22
+
pnpm build
22
23
```
23
24
24
25
## Commands you'll use
25
26
26
-
Run these from the repo root. You don't need to build before you run the tests.
27
+
Run these from the repo root. Tests and benchmarks reuse the built WPT package.
28
+
Rebuild it after changing its sources with `pnpm --filter @bomb.sh/web-platform-tests build`;
29
+
you can run tests repeatedly without rebuilding otherwise.
@@ -63,12 +66,13 @@ Use `expect.poll` here, because the screen doesn't update the moment you change
63
66
Before you push, make sure these pass:
64
67
65
68
```sh
69
+
pnpm build
66
70
pnpm lint
67
71
pnpm format:check
68
72
pnpm test
69
73
```
70
74
71
-
CI runs the same three on every pull request, along with the benchmarks and a workflow that publishes a preview build. In your PR, tell us why the change is needed and link the issue if there is one.
75
+
CI runs these checks on every pull request, building the WPT package once before tests or benchmarks. A separate workflow publishes a preview build. In your PR, tell us why the change is needed and link the issue if there is one.
Copy file name to clipboardExpand all lines: packages/ui/test/README.md
+8-5Lines changed: 8 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
# UI tests
2
2
3
-
Tests live alongside the implementation in `src/`; this directory contains their shared fixtures and WPT configuration. Run the UI tests from the workspace root:
3
+
Tests live in `src/` and this directory, alongside shared fixtures and WPT configuration. Run the UI tests from the workspace root:
4
4
5
5
```sh
6
6
pnpm --filter @clack/ui test
7
7
```
8
8
9
-
The test script builds the private `@bomb.sh/web-platform-tests` package before running Vitest. Use `pnpm test` from the workspace root to run the workspace tests.
9
+
Run `pnpm build` once before testing, and rebuild the private `@bomb.sh/web-platform-tests` package after changing its sources. Test commands reuse that build. Use `pnpm test` from the workspace root to run the workspace tests.
10
10
11
11
## Terminal fixtures
12
12
@@ -26,13 +26,16 @@ Rendering, scheduling, notifications, and lifecycle behavior belong in the UI te
26
26
27
27
The configuration explicitly excludes unsupported directories. Add includes or narrow exclusions as cases pass. Selecting a source runs all of our adapted cases from that file; it does not imply complete coverage of the upstream file or interface.
28
28
29
-
Include the source or case in the configuration while implementing it. Vitest's `-t` can narrow the configured selection by source path and case name:
29
+
Include the source or case in the configuration while implementing it. Run matching cases by supplying plain text from a source path or case name:
30
30
31
31
```sh
32
-
pnpm --filter @clack/ui test src/dom.compatibility.test.ts -t 'Document-createElement.html.*createElement\(foo\)'
32
+
pnpm wpt createElement
33
+
pnpm wpt 'createElement(foo) in HTML document'
33
34
```
34
35
35
-
If the shared package is already built, avoid rebuilding by using `pnpm --filter @clack/ui exec bsh test src/dom.compatibility.test.ts` with the same name filter.
36
+
The script invokes the package-owned `wpt` CLI, which uses `@bomb.sh/router` to parse arguments and launches Vitest with the UI test entrypoint. It reuses the existing WPT build. The search is a literal substring, so punctuation needs no regex escaping. Omit the search text (`pnpm wpt`) to run all configured cases. Matching happens before Vitest registers tests, so unrelated cases do not appear as skipped.
37
+
38
+
The root Vitest configuration imports `wptNameFilter()` from `@bomb.sh/web-platform-tests/vitest`; the UI entrypoint uses the worker adapter from `@bomb.sh/web-platform-tests/vitest/runner`. Direct Vitest runs still support `-t` regular expressions. Watch mode retains the full configured catalogue so changing its interactive name filter can discover other cases.
36
39
37
40
When implementing behavior, read the source-named file under [`src/wpt`](../../web-platform-tests/src/wpt), implement its operations, and update the configuration once its cases pass. Extend the fixture when cases need document parsing, host input, or cleanup. Implementation-specific rendering, notification, and lifecycle checks remain in the UI tests.
Copy file name to clipboardExpand all lines: packages/web-platform-tests/README.md
+34-4Lines changed: 34 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,21 +16,51 @@ The WPT suite must contain only faithful adaptations of existing upstream cases.
16
16
17
17
The shared suite is the long-term home of upstream WPT coverage for the UI. Implementation-specific rendering, notification, and lifecycle checks belong in the corresponding UI integration tests.
18
18
19
+
### Vitest integration
20
+
21
+
Register `wptNameFilter()` in the consumer's Vitest configuration:
The configuration plugin is safe to import outside a test worker. The separate worker adapter supplies Vitest's assertions and filters cases before registration. Direct Vitest `-t` filters work too; watch mode retains the full configured catalogue so interactive filter changes can discover other cases.
46
+
47
+
The main `@bomb.sh/web-platform-tests` entrypoint remains independent of Vitest. Other runners can use its `testDOMCompatibility()` with their own `runner: { describe, it, expect, filter? }`.
48
+
49
+
### CLI
50
+
51
+
The package provides a `wpt` executable using `@bomb.sh/router`. Install Vitest in the consuming workspace and build the WPT package before running it:
pnpm exec wpt --file path/to/dom.compatibility.test.ts 'createElement(foo) in HTML document'
57
+
pnpm exec wpt --help
58
+
```
59
+
60
+
`--file` selects the consumer's test entrypoint. `--config` optionally selects its Vitest configuration; otherwise Vitest discovers the configuration from the current working directory. Paths are relative to the caller, so the CLI does not depend on this repository's layout or package manager. The configuration must include `wptNameFilter()` and the entrypoint must use the worker adapter shown above.
61
+
62
+
Search text is an optional literal substring of a source path or case name. Multiple words are joined with spaces; use `--` before search text beginning with a dash. Omit the search to run all configured cases. The CLI forwards Vitest's exit status and never runs a build. Rebuild after changing WPT package sources, then reuse the output across focused runs.
63
+
34
64
### Selecting tests
35
65
36
66
The `config` option is optional; omitting it runs all adapted cases. A `WPTConfig` supplies source-path selectors in `include` and `exclude`; an explicit include always wins. Each value is `true` for the entire source file or an array of exact case names and regular expressions matching case names.
@@ -50,7 +80,7 @@ export default {
50
80
51
81
Source paths support `*` within a path segment and `**` across directories; `**/` also matches zero directories. Other characters are literal. Case-name strings match exactly. Empty, invalid, or unmatched selectors fail configuration before any cases register, so stale exclusions remain visible.
52
82
53
-
Cases have no test-to-test prerequisite gates. A selected case exercises its supporting DOM operations and reports failures normally. Globals and host input are resolved lazily when the case uses them. The runner can narrow selected cases further with its usual name filter.
83
+
Cases have no test-to-test prerequisite gates. A selected case exercises its supporting DOM operations and reports failures normally. Globals and host input are resolved lazily when the case uses them. An optional `runner.filter(source, name)` narrows configured cases before registering suites or tests with the runner. Configuration is still validated against the full catalogue. If this filter matches nothing, the harness registers nothing.
54
84
55
85
Run `pnpm generate` after adding, moving, or removing source files. The build also regenerates the registry from filenames. Only files exporting `register` are test entrypoints; upstream support files are imported by those tests. `node scripts/generate-registry.mjs --check` verifies that the checked-in registry is current.
0 commit comments