feat(ct): type the mount fixture via story template argument#41920
Conversation
Make the mount fixture generic over the story: mount<typeof MyStory>() type-checks props and update() against the story component signature. Works for React function/class components and Vue components; a plain props type can be passed directly for other frameworks. Document mount officially in class-fixtures.md.
04a1bce to
1f39349
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Test results for "MCP"2 failed 7790 passed, 1269 skipped Merge workflow run. |
|
Hi, I'm the Playwright bot and I took a look at the failing CI. 🟢 CI is clear — both failures are pre-existing MCP flakesThe two red tests are DetailsPre-existing flake / infra
Both were the only failures on their respective Triaged by the Playwright bot - agent run |
Test results for "tests 1"5 flaky50043 passed, 1190 skipped Merge workflow run. |
| await expect(component).toContainText('override initialState'); | ||
| }); | ||
| ``` | ||
| Yes — that is the core of the design. The gallery is served by your own dev server, so whatever your app can render, your stories can render. There is no second bundler config to keep in sync. |
There was a problem hiding this comment.
"...There is no second bundler config to keep in sync." - drop this part, we don't need to reference old implementation.
There was a problem hiding this comment.
I think it is benign
|
|
||
| test('should not report changes when read-only', async ({ mount, page }) => { | ||
| const component = await mount('components/codeMirrorWrapper/Editable', { readOnly: true }); | ||
| const component = await mount<typeof Editable>('components/codeMirrorWrapper/Editable', { readOnly: true }); |
There was a problem hiding this comment.
can we make it work without typeof everywhere?
There was a problem hiding this comment.
Not seeing the way currently.
Summary
mountis now generic over the story:mount<typeof MyStory>(id, props)type-checkspropsandupdate()against the story component signature (React function/class components, Vue components; a plain props type works for other frameworks)mountofficially inclass-fixtures.md