Skip to content

[Docs]: Svelte Component Testing Hooks #31367

Open
@sand4rt

Description

@sand4rt

Page(s)

https://playwright.dev/docs/next/test-components#hooks

// 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]
    ]),
  });
});
// context.test.ts
test('context', async ({ mount }) => {
  const component = await mount<HooksConfig>(Context, {
    hooksConfig: {
      context: 'context-value',
    }
  });
  await expect(component).toContainText('context-value');
});

Description

The hooks example for Svelte is missing

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions