Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 831 Bytes

Recording with Playwright.md

File metadata and controls

22 lines (15 loc) · 831 Bytes

Recording, Screenshots, and Snapshots

with Playwright

Typing stuff out is all well and good, but if we're looking to get some amount of coverage really quickly and we're willing to remember that there is a lot of value in just making sure everything is where we expect, we can get use Playwright's recording feature to get a sanity check quickly.

Screenshots

You can take a visual snapshot of a element or the entire page.

await expect(heading).toHaveScreenshot('heading.png');
await expect(heading).toHaveScreenshot('heading.png', { maxDiffPixels: 100 });

You can also just assert that an element has what you expect as it's text content.

const label = page.getByTestId('search-label');
await expect(await label.textContent()).toMatchSnapshot();