Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
scurker committed Jan 12, 2024
1 parent 31988a9 commit 677e2a9
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions e2e/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ yarn screenshots
Component testing is done in [`screenshots.test.tsx`](./screenshots.test.tsx). Non-interactive components can render a single component for screenshots:

```tsx
test('should have screenshot for Component', async ({ mount, page }) => {
const component = await mount(<Component prop="a" variant="b" />);
});
const component = await mount(<Component prop="a" variant="b" />);
```

There are additional helpers available under [`e2e/helpers`](./helpers/playwright.ts) for things like setting the current Cauldron theme. In order to provide sufficient coverage, components should have snapshots for both light and dark Cauldron themes:
Expand All @@ -47,19 +45,17 @@ await expect(component).toHaveScreenshot('dark--component');
For interactive components, remember to test all the different states (focus, hover, disabled, etc):

```tsx
test('should have screenshot for Button', async ({ mount, page }) => {
const component = await mount(
<div>
<Button>Button</Button>
<Button>Hover</Button>
<Button>Active</Button>
<Button>Focus</Button>
<Button disabled>Disabled</Button>
</div>
);

await component.getByText('Hover').hover();
setActive(await component.getByText('Active'));
await component.getByText('Focus').focus();
});
const component = await mount(
<div>
<Button>Button</Button>
<Button>Hover</Button>
<Button>Active</Button>
<Button>Focus</Button>
<Button disabled>Disabled</Button>
</div>
);

await component.getByText('Hover').hover();
setActive(await component.getByText('Active'));
await component.getByText('Focus').focus();
```

0 comments on commit 677e2a9

Please sign in to comment.