Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kumaraditya303/pytest-playwright-snapshot
https://github.com/kumaraditya303/pytest-playwright-snapshot
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/kumaraditya303/pytest-playwright-snapshot
- Owner: kumaraditya303
- Created: 2021-06-28T08:57:26.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-18T03:22:54.000Z (over 2 years ago)
- Last Synced: 2024-10-12T07:34:24.950Z (25 days ago)
- Language: Python
- Size: 22.5 KB
- Stars: 22
- Watchers: 2
- Forks: 20
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Pytest Plugin for Snapshot Testing with Playwright
This plugin enables snapshot testing in playwright like snapshotting screenshots of pages, element handles etc.
## Installation
```bash
$ pip install pytest-playwright-snapshot
```## Usage
This plugin provides a `assert_snapshot` fixture which is used to create snapshots and compare it.
Example:
```python
def test_myapp(page, assert_snapshot):
page.goto("https://example.com")
assert_snapshot(page.screenshot(), "example.png")
```Ths first time you run pytest, you will get error like
```console
Failed: Snapshot not found, use --update-snapshots to create it.
```As first you need to create golden snapshots to which this plugin will compare in future.
To create snapshots run:
```bash
$ pytest --update-snapshots
```This will create snapshots for your tests, after that you can run the tests are usual and this will compare the snapshots.
There is `threshold` kwarg only option which can be used to set the threshold for the comparison of the screenshots and by default it is `0.1`
## License
Apache 2.0 LICENSE