Skip to content

feat(ct): type mount() story ids through a generated Stories registry - #42518

Merged
Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
pavelfeldman:fix-42083
Sep 3, 2026
Merged

feat(ct): type mount() story ids through a generated Stories registry#42518
Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
pavelfeldman:fix-42083

Conversation

@pavelfeldman

Copy link
Copy Markdown
Member

Summary

  • @playwright/test exports an empty Stories interface; mount(id, props) types props and update() from Stories[id] when the id is registered, keeps untyped props otherwise, and the explicit mount<typeof Story>(id, props) form still works.
  • A Vite plugin next to the html-reporter gallery generates stories.d.ts (one line per story file, ids prefixed with the package name) and augments Stories; the gallery moves to packages/html-reporter/tests.
  • The component testing skill documents both typing forms and includes the plugin.

Fixes #42083

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread packages/html-reporter/tests/stories.d.ts
`@playwright/test` now exports an empty `Stories` interface. When a story
id is a key of it, `mount(id, props)` types the props (and `update()`) from
that entry, unregistered ids keep untyped props, and the explicit
`mount<typeof Story>(id, props)` form keeps working.

A small Vite plugin next to the html-reporter gallery generates
`stories.d.ts`, one `StoriesOf<'<package>/<path>', typeof import(...)>`
line per story file, and augments `Stories` with it. Ids are prefixed with
the package name so registries from several packages can share one
TypeScript program. The gallery moves to `packages/html-reporter/tests`.

The component testing skill documents both typing forms and ships the
plugin as a reference.

Fixes: microsoft#42083
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

6 flaky ⚠️ [chromium-library] › library/video.spec.ts:736 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node24`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:257 › third party 'Partitioned;' cookies `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:470 › top level 'Partitioned;' cookie and same origin iframe `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-page] › page/page-emulate-media.spec.ts:144 › should keep reduced motion and color emulation after reload `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-page] › page/page-event-request.spec.ts:181 › should return response body when Cross-Origin-Opener-Policy is set `@firefox-ubuntu-22.04-node20`
⚠️ [webkit-library] › library/browsercontext-storage-state.spec.ts:655 › should not leave IndexedDB connections open `@webkit-ubuntu-22.04-node20`

51326 passed, 1247 skipped


Merge workflow run.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Test results for "MCP"

1 failed
❌ [chrome] › mcp/cli-test.spec.ts:23 › debug test and snapshot @mcp-ubuntu-latest-chrome

8274 passed, 1371 skipped


Merge workflow run.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🟢 The one failure is a pre-existing flake — this PR is clear

Hi, I'm the Playwright bot and I took a look at the failing CI on this PR.

Only ubuntu-latest - chrome failed, on a single MCP test: mcp/cli-test.spec.ts:23 › debug test and snapshot. This PR only touches component-testing typing (html-reporter gallery, Stories types, generate_types, and CT skill docs) — nothing under tests/mcp/ or the MCP/CLI product code the test exercises. The same test also flakes on commits this PR can't be responsible for, so I'm calling it noise.

Details

Overall: 43 of 44 checks green. The lone red is one MCP test on Chrome, in a code path the diff doesn't reach. No caused-by-PR failures.

Pre-existing flake / infra

  • [chrome] › tests/mcp/cli-test.spec.ts:23:5 › debug test and snapshotexpect(listOutput3).toContain('(no browsers)') failed because a browser context from an earlier test was still attached (tw-bbc164 … browser-type: chromium (attached)), so list reported an open browser instead of (no browsers). That's a state-leak flake, not a typing change.
    • Across the CI results DB this test's final verdict is green in 723/723 Chrome runs — it never fails outright — but it has flaked within a run on commits unrelated to this PR: a push to main (sha bee00ad3) and PR chore(net): use native happy eyeballs instead of the manual implementation #42240. Same (project, file, title), so this PR isn't the cause.
    • The diff is confined to packages/html-reporter/**, packages/playwright/types/test.d.ts, utils/generate_types/**, and the playwright-component-testing skill — none of which the MCP CLI flow imports or touches.

A re-run of the Chrome MCP job should go green.

Triaged by the Playwright bot - agent run

@pavelfeldman
Pavel Feldman (pavelfeldman) merged commit bfb42e5 into microsoft:main Sep 3, 2026
45 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Improved type safety for component testing

2 participants