Skip to content

docs(component testing): add Svelte hooks example #36491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ARMeeru
Copy link

@ARMeeru ARMeeru commented Jun 29, 2025

This patch adds the missing Svelte component testing hooks example to the documentation, showing how to use beforeMount and afterMount hooks with hooksConfig for setting up component context.

Fixes #31367

This patch adds the missing Svelte component testing hooks example
to the documentation, showing how to use beforeMount and afterMount
hooks with hooksConfig for setting up component context.

Fixes microsoft#31367
@ARMeeru
Copy link
Author

ARMeeru commented Jun 29, 2025

@microsoft-github-policy-service agree

import type { HooksConfig } from '../playwright';
import Context from './Context.svelte';

test('context', async ({ mount }) => {
Copy link
Collaborator

@sand4rt sand4rt Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text becomes inaccurate when an example other than a router example is used:

https://github.com/microsoft/playwright/pull/36491/files#diff-01a9511ee9b7ad42036d13215896685a8a186c32b480690fad5bb1a3786dc25fR470

"An example of configuring a router is provided below"

I would suggest replacing all examples with a "dependency injection" example rather than a routing example to ensure consistency. This approach essentially reflects what libraries like routers use under the hood (with the exception of Svelte).

For reference, see:

Let’s wait for the Playwright team to confirm they’re okay with this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let's wait for the team to verify. Thanks for the pointer anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not touch the existing react example.

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.

[Docs]: Svelte Component Testing Hooks
3 participants