Skip to content

Commit c815e2f

Browse files
authored
feat: Update dependencies like its mid july 2023 (#238)
* Start to migrate Cypress and update everything * All ts now * Use constants to avoid typos and reuse * Single command to setup all commands and constants for keepig typos in bay * Still figuring out how would Cypress API allow various calls * Back and forth... * Move the cy.task call in the same place where it was earlier for easier comparison * Mention the minimum Cypress version * Update usage documentation
1 parent 61dc5c8 commit c815e2f

File tree

20 files changed

+14467
-2616
lines changed

20 files changed

+14467
-2616
lines changed

README.md

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,27 @@ Npm: https://www.npmjs.com/package/@visual-regression-tracker/agent-cypress
66

77
## Installation
88

9+
Please note that the minimum supported Cypress version is [`12.17.1`, released in 10th July 2023](https://docs.cypress.io/guides/references/changelog#12-17-1).
10+
911
### Add package
1012

1113
`npm install @visual-regression-tracker/agent-cypress`
1214

13-
### Add command
15+
### Add commands
16+
17+
`<rootDir>/cypress/support/e2e.js` or `<rootDir>/cypress/support/component.js`
18+
19+
All available commands:
20+
21+
```js
22+
import {
23+
addVrtCommands,
24+
} from "@visual-regression-tracker/agent-cypress";
25+
26+
addVrtCommands();
27+
```
1428

15-
`<rootDir>/cypress/support/commands.js`
29+
or one by one:
1630

1731
```js
1832
import {
@@ -21,7 +35,7 @@ import {
2135
addVrtStopCommand,
2236
addVrtTrackBufferCommand,
2337
addVrtTrackBase64Command,
24-
} from "@visual-regression-tracker/agent-cypress/dist/commands";
38+
} from "@visual-regression-tracker/agent-cypress";
2539

2640
addVrtStartCommand();
2741
addVrtStopCommand();
@@ -32,27 +46,32 @@ addVrtTrackBase64Command();
3246

3347
### Add plugin
3448

35-
`<rootDir>/cypress/plugins/index.js`
49+
`<rootDir>/cypress.config.js`
3650

3751
```js
38-
const {
39-
addVisualRegressionTrackerPlugin,
40-
} = require("@visual-regression-tracker/agent-cypress/dist/plugin");
41-
42-
module.exports = (on, config) => {
43-
addVisualRegressionTrackerPlugin(on, config);
44-
};
52+
import { defineConfig } from 'cypress';
53+
import { addVisualRegressionTrackerPlugin } from "@visual-regression-tracker/agent-cypress";
54+
55+
export default defineConfig({
56+
// e2e or component, depending of testing style
57+
e2e: {
58+
setupNodeEvents (on, config) => {
59+
addVisualRegressionTrackerPlugin(on, config);
60+
}
61+
}
62+
});
4563
```
4664

4765
### Configuration
4866

49-
#### Update cypress config
67+
#### Update Cypress config
5068

51-
`<rootDir>/cypress.json`
69+
`<rootDir>/cypress.config.js`
5270

5371
```js
54-
{
55-
"env": {
72+
export default defineConfig({
73+
74+
env: {
5675
"visualRegressionTracker": {
5776
// URL where backend is running
5877
// Required
@@ -83,7 +102,7 @@ module.exports = (on, config) => {
83102
"ciBuildId": "SOME_UNIQUE_ID",
84103
}
85104
}
86-
}
105+
});
87106
```
88107

89108
#### Or, as JSON config file `vrt.json`

cypress.config.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { defineConfig } from 'cypress';
2+
import { addVisualRegressionTrackerPlugin } from "./lib/plugin";
3+
4+
/**
5+
* @see https://docs.cypress.io/guides/references/configuration
6+
*/
7+
export default defineConfig({
8+
e2e: {
9+
baseUrl: "https://example.cypress.io",
10+
specPattern: 'cypress/integration/*.spec.ts',
11+
12+
setupNodeEvents(on, config) {
13+
// `on` is used to hook into various events Cypress emits
14+
// `config` is the resolved Cypress config
15+
addVisualRegressionTrackerPlugin(on, config);
16+
},
17+
},
18+
video: false,
19+
screenshotOnRunFailure: false,
20+
retries: 0,
21+
env: {
22+
"visualRegressionTracker": {
23+
"apiUrl": "http://localhost:4200",
24+
"apiKey": "5H90NFWM6BMWWDMWKG8T11DWW22Y",
25+
"project": "fcf9ab05-4bed-40d6-a033-c178948c9897",
26+
"branchName": "master",
27+
"enableSoftAssert": false
28+
}
29+
}
30+
});

cypress.json

Lines changed: 0 additions & 15 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

cypress/plugins/index.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

cypress/support/commands.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

cypress/support/e2e.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @see https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests#Support-file
3+
*/
4+
import {
5+
addVrtTrackCommand,
6+
addVrtStartCommand,
7+
addVrtStopCommand,
8+
} from "../../lib/commands";
9+
10+
addVrtStartCommand();
11+
addVrtStopCommand();
12+
addVrtTrackCommand();

0 commit comments

Comments
 (0)