1.0.0 • Published 1 year ago

storybook-playwright-ct v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Get Started

!IMPORTANT
Requirements: storybook v8

// playwright-ct.config.ts
import { defineConfig } from 'storybook-playwright-ct';

export default defineConfig({
  testMatch: '**/*.stories.spec.{ts,tsx}',
  webServer: {
    command: 'npm run storybook',
    url: 'http://localhost:6006/',
    reuseExistingServer: true,
  },
});
// stories/Button.stories.spec.tsx
import { composeStories } from '@storybook/react';
import { expect, test } from 'storybook-playwright-ct';
import * as stories from './Button.stories';

const { Primary } = composeStories(stories);

test('Screenshot', async ({ mount }) => {
  const component = await mount(<Primary />);

  await expect(component).toHaveScreenshot();
});

test('Event callback', async ({ mount }) => {
  let eventType;
  const component = await mount(<Primary onClick={(ev) => (eventType = ev.type)} />);

  await component.click();
  await expect(eventType).toBe('click');
});
{
  "scripts": {
    "test:ct": "playwright test --config playwright-ct.config.ts"
  }
}

Credits

1.0.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago