playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Docs]: Svelte Component Testing Hooks

Open sand4rt opened this issue 1 year ago • 0 comments

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

sand4rt avatar Jun 18 '24 16:06 sand4rt