playwright/docs/src/test-snapshots.md

19 lines
653 B
Markdown
Raw Normal View History

2021-05-27 20:30:03 -07:00
---
id: test-snapshots
title: "Snapshots"
---
Playwright Test includes the ability to produce and compare snapshots. For that, use `expect(value).toMatchSnapshot()`. Test runner auto-detects the content type, and includes built-in matchers for text, png and jpeg images, and arbitrary binary data.
2021-05-28 17:02:23 -07:00
```js
2021-05-27 20:30:03 -07:00
// example.spec.ts
import { test } from 'playwright/test';
test('my test', async () => {
const image = await produceSomePNG();
test.expect(image).toMatchSnapshot('optional-snapshot-name.png');
});
```
Snapshots are stored under `__snapshots__` directory by default, and can be specified in the [configuration object](#configuration-object).