Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/src/test-components-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ You can use `beforeMount` and `afterMount` hooks to configure your app. This let
defaultValue="react"
values={[
{label: 'React', value: 'react'},
{label: 'Svelte', value: 'svelte'},
{label: 'Vue', value: 'vue'},
]
}>
Expand Down Expand Up @@ -457,6 +458,39 @@ You can use `beforeMount` and `afterMount` hooks to configure your app. This let

</TabItem>

<TabItem value="svelte">

```js title="playwright/index.ts"
import { beforeMount, afterMount } from '@playwright/experimental-ct-svelte/hooks';

export type HooksConfig = {
context?: string;
}

beforeMount<HooksConfig>(async ({ hooksConfig, App }) => {
return new App({
context: new Map([
['context-key', hooksConfig?.context]
]),
});
});
```

```js title="src/context.spec.ts"
import { test, expect } from '@playwright/experimental-ct-svelte';
import type { HooksConfig } from '../playwright';
import Context from './Context.svelte';

test('provide context through hooks config', async ({ mount }) => {
const component = await mount<HooksConfig>(Context, {
hooksConfig: { context: 'context-value' },
});
await expect(component).toContainText('context-value');
});
```

</TabItem>

<TabItem value="vue">

```js title="playwright/index.ts"
Expand Down