microsoft/webui/testing
Claude Code and agent skill by microsoft/webui
- vendor
Checking that the SKILL.md file is still in the repository.
Test patterns, fixture structure, and when to use E2E vs unit tests.
Install
npx vskill@latest install microsoft/webui/testingSKILL.md
The same SKILL.md was published earlier as microsoft/webui/testing.
Testing
Use this skill when writing or modifying tests in this repository.
Rust crate tests
Unit tests live alongside code in #[cfg(test)] modules. Integration tests go in each crate's tests/ directory.
Every code change ships with tests:
| Change type | Requirement | |
|---|---|---|
| New public API | At least one unit test per function/method | |
| Bug fix | Regression test that fails without the fix | |
| Performance change | Benchmark comparison (before/after) | |
| Refactor | Existing tests pass unchanged |
Never remove, weaken, or #[ignore] an existing test unless explicitly asked.
Windows native UI tests
Desktop SDK tests that create native Windows windows or initialize the native UI dispatcher remain #[ignore] for direct cargo test, including hidden-window and fullscreen-presenter checks. Do not treat an initially hidden HWND as headless: native presenter transitions can activate windows. On Windows, cargo xtask check, cargo xtask test, cargo xtask test-desktop, and cargo xtask desktop-acceptance automatically run the native SDK suite with native-dwm-frame and --include-ignored, followed by the opt-in native-services suite. Both run serially through an internal helper: local runs use non-input desktops, while GitHub Actions (GITHUB_ACTIONS=true) uses the current desktop in its dedicated runner VM. The suites and native assertions are identical in both modes. Ordinary cargo test keeps the SDK's non-UI tests. Browser E2E tests use Playwright's default headless mode.
Windows CI uses the same desktop suite through desktop-acceptance, rather than repeating native SDK and services tests in separate steps. The isolation helper's visible-window/focus regression runs as an ordinary xtask test; its child always verifies alternate-desktop isolation before creating any HWND, including in CI. A separate non-UI probe verifies current-desktop execution.
To run the native tests without interrupting the Windows desktop:
Locally, the internal Windows-only helper creates one non-input desktop per suite, not per test. GitHub Actions retains the original current-desktop execution because elevated WebView2 initialization on alternate desktops can fail. The execution policy is selected before launch, not as a fallback after a failure. The helper never switches the input desktop or changes application visibility. It preserves standard I/O and exit codes, bounds each command to 1800 seconds, and terminates remaining child processes when the command completes or fails. Failure to establish local isolation fails the gate rather than running on the user's desktop. There is no standalone isolated-desktop command. cargo xtask native-ipc uses the same policy for its Windows release acceptance run: automatic alternate-desktop execution locally, original current-desktop execution in GitHub Actions. This heavier source/package suite remains a separate CI step. macOS and Linux native execution is unchanged. Direct cargo test ... --ignored remains an explicit headed debugging option. Physical-input and active-compositor tests still need an interactive Windows session; do not assume alternate-desktop execution is equivalent.
Keep the native visibility, focus, and geometry assertions intact; do not make them appear headless by suppressing the window behavior they verify.
WebUI Node package tests
Framework and delivery unit tests emit to dist-test/, never public dist/. The E2E runner builds public packages before starting suites in parallel; delivery's bundle-boundary tests and browser fixtures consume those immutable public outputs while unit compilers write their private test outputs. Keep the unit runner glob aligned with its compiler output directory.
cargo xtask test builds the host native addon and the WebUI TypeScript package, then runs pnpm --filter @microsoft/webui test with WEBUI_ADDON_PATH set to the artifact reported by Cargo. This includes the projection compiler, adapter, class-factory, parser, and native build/render regressions in both the local cargo xtask check gate and the PR Test job. Browser suites run separately via cargo xtask e2e.
Shared test utilities (webui-test-utils)
The webui-test-utils crate provides common Rust test helpers, builders, and fixtures. Check it before writing new helpers - avoid duplicating across crates.
Docs component tests
Colocate docs component tests under docs/.webui-press/components/<component>/, for example benchmark-preview/benchmark-preview.test.ts. Keep component coverage with its owner rather than in packages/webui-press/tests/.
Keep tutorial tests beside the Markdown lessons in docs/start/ and site-navigation tests beside their regions in docs/.webui-press/regions/. The shared Press runner includes these tests through pnpm --filter @microsoft/webui-press test. Its build:test command type-checks and bundles these locations into dist-test; use unique owner-prefixed test filenames. Reuse the existing native and website fixture helpers. Test modules are not component runtime entries and must not enter the published site.
webui-framework E2E fixtures
The packages/webui-framework package uses Playwright for E2E tests. Each fixture is a mini WebUI app compiled and rendered by the real pipeline.
See tests/fixtures/README.md for the full reference.
Fixture structure
How it works
The test server (fixture-render.ts) auto-discovers fixtures with src/index.html, calls @microsoft/webui build() + render() to produce SSR HTML with template IIFEs, hydration markers, and inventory. The result is served at /<name>/fixture.html.
Creating a new fixture
- Create
fixtures/<name>/src/index.html— page template:
- Create
fixtures/<name>/src/test-widget/test-widget.html— component template:
- Create
fixtures/<name>/state.json— initial state:
- Create
fixtures/<name>/element.ts— component class only:
- Create
fixtures/<name>/<name>.spec.ts— Playwright tests:
Template syntax quick reference
| Feature | Syntax | |
|---|---|---|
| Text binding | {{propertyName}} | |
| Event binding | @click="{handler()}" or @click="{handler(e)}" | |
| Boolean attribute | ?disabled="{{isDisabled}}" | |
| Dynamic attribute | href="{{url}}" | |
| Mixed attribute | href="/items/{{id}}" | |
| Complex property | :items="{{items}}" | |
| Element ref | w-ref="{myElement}" | |
| Conditional | <if condition="show">...</if> | |
| Negation | <if condition="!hidden">...</if> | |
| Comparison | <if condition="count > 0">...</if> | |
| Compound | <if condition="active && !busy">...</if> | |
| Loop | <for each="item in items">...</for> | |
| Nested loop | <for each="group in groups">...<for each="item in group.items">...</for></for> | |
| Shadow DOM | <template shadowrootmode="open">...</template> | |
| Root event | <template shadowrootmode="open" @click="{handler(e)}"> | |
| Slot | <slot></slot> |
Dynamic children pattern
Components only created via document.createElement() (not in any template) need a false <if> in the page template to make their template IIFEs available:
With state.json: { "showChild": false }.
Per-fixture build config
Create webui.config.json to override build options:
Light and Shadow fixtures
Ordinary unwrapped fixture components exercise the Shadow default. Set "dom": "light" in webui.config.json to exercise global Light rendering; a fixture component requiring Shadow inside that build must author a sole top-level <template shadowrootmode="open">. A sole bare top-level <template> explicitly exercises Light even in the default Shadow fixture. See fixtures/dom-default/ and fixtures/light-dom/ for both paths through the real pipeline. Reserve manual registerCompiledTemplate fixtures for raw template-metadata scenarios.
Running framework E2E tests
Test support package (@microsoft/webui-test-support)
The packages/webui-test-support package provides:
- `registerCompiledTemplate(name, meta)` — register a raw
TemplateMetaobject (for manual/light-DOM fixtures) - `renderTemplateScript(name, meta)` — render a template as an inline
<script>tag - `renderFixtures({ fixturesRoot })` — build+render all pipeline fixtures
- `buildFixtureEntries({ ... })` — bundle element.ts files via esbuild
- `startFixtureServer({ ... })` — start the HTTP fixture server
When to use what
| Scenario | Tool | |
|---|---|---|
| Rust crate logic (parsing, rendering, state, expressions) | #[test] unit tests | |
| Rust crate integration (full pipeline) | tests/ integration tests | |
| Rust performance | cargo bench with Criterion | |
| Framework hydration, reactive updates, DOM behavior | Playwright E2E fixtures | |
| Router navigation, lazy loading, chain diffing | Playwright E2E fixtures | |
| Template metadata encoding/decoding | Node unit tests (pnpm test:unit) |
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 8 Jul 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/testing/SKILL.md
Popularity
- Repository stars
- 49
- Repository forks
- 13
- 7-day trend score
- 20
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/microsoft/webui/testing)