Skip to content

Commit 6e32210

Browse files
committed
docs: add examples to the README
rename plugin.ts into plugins.ts
1 parent cad93fd commit 6e32210

File tree

3 files changed

+58
-5
lines changed

3 files changed

+58
-5
lines changed

README.md

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@
1212

1313
<p align="center">
1414
<img src="https://github.com/FRSOURCE/cypress-plugin-visual-regression-diff/blob/main/src/assets/logo.svg" alt="Cypress Plugin Visual Regression Diff logo" height="120px"/>
15-
<br>
1615
</p>
1716

18-
<h1 align="center">Cypress Plugin Visual Regresion Diff</h1>
17+
<h1 align="center">Plugin for Cypress - Visual Regression Diff</h1>
1918
<p align="center">Perform visual regression test with a nice GUI as help. 💅 <i>Only&nbsp;for&nbsp;Cypress!</i></p>
2019

2120
<p align="center">
2221
<a href="#getting-started">Getting Started</a>
2322
·
24-
<a href="#documentation">Documentation</a>
23+
<a href="#usage">Usage</a>
2524
·
2625
<a href="https://github.com/FRSOURCE/cypress-plugin-visual-regression-diff/issues">File an Issue</a>
2726
·
@@ -44,9 +43,63 @@
4443

4544
## Getting started
4645

46+
### Installation
47+
48+
You can install this library using your favorite package manager:
49+
50+
```bash
51+
# yarn
52+
yarn add -D @frsource/cypress-plugin-visual-regression-diff
53+
54+
# npm
55+
npm install --save-dev @frsource/cypress-plugin-visual-regression-diff
56+
```
57+
58+
Next, you need to import the library:
59+
60+
- once, in your support file (located by default in `cypress/support/index.js`):
61+
```ts
62+
// typescript
63+
import '@frsource/cypress-plugin-visual-regression-diff/src/support';
64+
65+
// javascript
66+
require('@frsource/cypress-plugin-visual-regression-diff/dist/support');
67+
```
68+
69+
- seconds time, in your plugins file (located by default in `cypress/plugins/index.js`):
70+
```ts
71+
// typescript
72+
import '@frsource/cypress-plugin-visual-regression-diff/src/plugins';
73+
74+
// javascript
75+
require('@frsource/cypress-plugin-visual-regression-diff/dist/plugins');
76+
```
77+
78+
That's it - now let's see how to use the library in [usage section](#usage).
79+
80+
## Usage
81+
82+
Once installed, the library might be used by writing in your test:
83+
84+
```ts
85+
cy.get('.an-element-of-your-choice').matchImage();
86+
```
87+
88+
Or, if you would like to make a screenshot of whole document:
89+
90+
```ts
91+
cy.matchImage();
92+
```
93+
94+
`matchImage` command will do a screenshot and compare it with image from a previous run. In case of regression the test will fail and you'll get a "Compare images" button to see what's a root of a problem.
95+
96+
## Configuration
97+
98+
This plugin can be configured either:
4799

48-
## Documentation
100+
- via global env configuration,
49101

102+
- directly, on a matcher level - by passing in plugin options as an argument to `matchImage` command,
50103

51104
## Questions
52105

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"sideEffects": false,
88
"license": "MIT",
99
"scripts": {
10-
"build": "del-cli dist && microbundle src/{constants,plugin,support}.ts -f cjs,esm",
10+
"build": "del-cli dist && microbundle src/{constants,plugins,support}.ts -f cjs,esm",
1111
"lint": "eslint '**/*.ts' --ignore-pattern '**/*.d.ts'",
1212
"lint.fix": "yarn lint --fix",
1313
"lint.ci": "yarn lint --max-warnings 0",
File renamed without changes.

0 commit comments

Comments
 (0)