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
[Docs]: Component testing "best practices" or "pitfalls" #31361
Suggestion from Dmitry Gozman (@dgozman) to include a "best practices" or "pitfalls" section for component testing: #31339 (comment). I've created a ticket to track this so I don't forget.
took a look at #39780 and the original concern from #31339.
the gap in the closed PR was that the content could have been written without CT-specific knowledge. generic testing advice applied to CT, nothing that required knowing about the Node/browser split.
I'd like to document the sharp edges the Node/browser split actually introduces:
module mocking doesn't cross the boundary: vi.mock / jest.mock runs Node-side, the component is browser-side; the correct pattern is hooksConfig + beforeMount in playwright/index.ts
context/page reuse: CT reuses context and page between tests as a performance optimization; what that means for test isolation and when it matters
each item is specific to CT's architecture and wouldn't apply to Jest-based component tests or regular Playwright tests.
Activity
dgozman commentedon Jun 18, 2024
This looks like a good starting point. If anything, some of these topics might be relevant in e2e best practices as well.
docs(ct): add component testing best practices section
mvanhorn commentedon Mar 19, 2026
Submitted a PR for this: #39780. Covers all 8 topics from the issue outline.
bwyard commentedon Apr 5, 2026
took a look at #39780 and the original concern from #31339.
the gap in the closed PR was that the content could have been written without CT-specific knowledge. generic testing advice applied to CT, nothing that required knowing about the Node/browser split.
I'd like to document the sharp edges the Node/browser split actually introduces:
beforeEach({ mount })antipattern: handle scoping and why it doesn't compose cleanly with test isolation (this was the original concern in [Feature]: Removal ofmount()insidetest.beforeEach()andtest.afterAll()#31339)vi.mock/jest.mockruns Node-side, the component is browser-side; the correct pattern ishooksConfig+beforeMountinplaywright/index.tscontextandpagebetween tests as a performance optimization; what that means for test isolation and when it matterseach item is specific to CT's architecture and wouldn't apply to Jest-based component tests or regular Playwright tests.
does that scope match what you had in mind, or are there pitfalls from support issues worth adding? Sander (@sand4rt) Dmitry Gozman (@dgozman)
ayushozha commentedon Apr 6, 2026
Opened a draft PR for this: #40064