This repository has been archived by the owner on Oct 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from argos-ci/docs
Improve documentation
- Loading branch information
Showing
4 changed files
with
70 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,20 @@ | ||
# @argos-ci/puppeteer | ||
<p align="center"> | ||
<a href="https://argos-ci.com/?utm_source=github&utm_medium=logo" target="_blank"> | ||
<img src="https://raw.githubusercontent.com/argos-ci/argos/main/resources/logos/logo-github-readme.png" alt="Argos" width="300" height="61"> | ||
</a> | ||
</p> | ||
|
||
[Puppeteer](https://pptr.dev/) commands and utilities for [Argos](https://argos-ci.com) visual testing. | ||
_Argos is a visual testing solution that fits in your workflow to avoid visual regression. Takes screenshots on each commit and be notified if something changes._ | ||
|
||
# Official Argos Puppeteer integration | ||
|
||
[![npm version](https://img.shields.io/npm/v/@argos-ci/puppeteer.svg)](https://www.npmjs.com/package/@argos-ci/puppeteer) | ||
[![npm dm](https://img.shields.io/npm/dm/@argos-ci/puppeteer.svg)](https://www.npmjs.com/package/@argos-ci/puppeteer) | ||
[![npm dt](https://img.shields.io/npm/dt/@argos-ci/puppeteer.svg)](https://www.npmjs.com/package/@argos-ci/puppeteer) | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install --save-dev @argos-ci/puppeteer | ||
``` | ||
|
||
## Usage | ||
|
||
Stabilizes the UI before taking a screenshot. | ||
|
||
`argosScreenshot(page, name[, options])` | ||
|
||
- `page` - A `puppeteer` page instance | ||
- `name` - The screenshot name; must be unique | ||
- `options` - See [Page.screenshot command options](https://pptr.dev/next/api/puppeteer.page.screenshot/) | ||
- `options.element` - Accept an ElementHandle or a string selector to screenshot an element | ||
|
||
```js | ||
describe("Integration test with visual testing", () => { | ||
it("Loads the homepage", async () => { | ||
const browser = await puppeteer.launch(); | ||
const page = await browser.newPage(); | ||
await page.goto(TEST_URL); | ||
await argosScreenshot(page, this.test.fullTitle()); | ||
}); | ||
}); | ||
``` | ||
|
||
Screenshots are stored in `screenshots/argos` folder, relative to current directory. | ||
|
||
### Helper attributes | ||
|
||
The `data-visual-test` attributes allow you to control how elements behave in the Argos screenshot. | ||
|
||
It is often used to hide changing element like dates. | ||
Visit [docs.argos-ci.com/puppeteer](https://docs.argos-ci.com/puppeteer) for guides, API and more. | ||
|
||
- `[data-visual-test="transparent"]` - Make the element transparent (`opacity: 0`) | ||
- `[data-visual-test="removed"]` - Remove the element (`display: none`) | ||
- `[data-visual-test="blackout"]` - Blacked out the element | ||
## Links | ||
|
||
```html | ||
<!-- Hide a div from a screenshot --> | ||
<div id="clock" data-visual-test="transparent">...</div> | ||
``` | ||
- [Official SDK Docs](https://docs.argos-ci.com/) | ||
- [Discord](https://discord.gg/pK79sv85Vg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters