@visual-regression-tracker/agent-cypress 5.6.0 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +4 -2
- package/.github/workflows/release.yml +6 -3
- package/LICENSE +201 -0
- package/README.md +35 -16
- package/cypress.config.ts +30 -0
- package/dist/commands.d.ts +9 -0
- package/dist/commands.js +49 -41
- package/dist/index.d.ts +2 -47
- package/dist/index.js +11 -0
- package/dist/plugin.d.ts +8 -1
- package/dist/plugin.js +51 -93
- package/dist/types.d.ts +47 -0
- package/dist/types.js +3 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +40 -42
- package/package.json +18 -12
package/.github/workflows/ci.yml
CHANGED
|
@@ -9,10 +9,12 @@ jobs:
|
|
|
9
9
|
runs-on: ubuntu-latest
|
|
10
10
|
|
|
11
11
|
steps:
|
|
12
|
-
- uses: actions/checkout@
|
|
12
|
+
- uses: actions/checkout@v3
|
|
13
13
|
|
|
14
14
|
- name: Setup Node.js environment
|
|
15
|
-
uses: actions/setup-node@
|
|
15
|
+
uses: actions/setup-node@v3
|
|
16
|
+
with:
|
|
17
|
+
node-version: 16
|
|
16
18
|
|
|
17
19
|
- name: Install npm dependencies
|
|
18
20
|
run: npm ci
|
|
@@ -6,15 +6,18 @@ on:
|
|
|
6
6
|
jobs:
|
|
7
7
|
release:
|
|
8
8
|
name: Release
|
|
9
|
-
runs-on: ubuntu-
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
10
11
|
steps:
|
|
11
12
|
- name: Checkout
|
|
12
|
-
uses: actions/checkout@
|
|
13
|
+
uses: actions/checkout@v3
|
|
13
14
|
with:
|
|
14
15
|
fetch-depth: 0
|
|
15
16
|
|
|
16
17
|
- name: Setup Node.js environment
|
|
17
|
-
uses: actions/setup-node@
|
|
18
|
+
uses: actions/setup-node@v3
|
|
19
|
+
with:
|
|
20
|
+
node-version: 18
|
|
18
21
|
|
|
19
22
|
- name: Install dependencies
|
|
20
23
|
run: npm ci
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -6,13 +6,27 @@ Npm: https://www.npmjs.com/package/@visual-regression-tracker/agent-cypress
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
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
|
+
|
|
9
11
|
### Add package
|
|
10
12
|
|
|
11
13
|
`npm install @visual-regression-tracker/agent-cypress`
|
|
12
14
|
|
|
13
|
-
### Add
|
|
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
|
+
```
|
|
14
28
|
|
|
15
|
-
|
|
29
|
+
or one by one:
|
|
16
30
|
|
|
17
31
|
```js
|
|
18
32
|
import {
|
|
@@ -21,7 +35,7 @@ import {
|
|
|
21
35
|
addVrtStopCommand,
|
|
22
36
|
addVrtTrackBufferCommand,
|
|
23
37
|
addVrtTrackBase64Command,
|
|
24
|
-
} from "@visual-regression-tracker/agent-cypress
|
|
38
|
+
} from "@visual-regression-tracker/agent-cypress";
|
|
25
39
|
|
|
26
40
|
addVrtStartCommand();
|
|
27
41
|
addVrtStopCommand();
|
|
@@ -32,27 +46,32 @@ addVrtTrackBase64Command();
|
|
|
32
46
|
|
|
33
47
|
### Add plugin
|
|
34
48
|
|
|
35
|
-
`<rootDir>/cypress
|
|
49
|
+
`<rootDir>/cypress.config.js`
|
|
36
50
|
|
|
37
51
|
```js
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
+
});
|
|
45
63
|
```
|
|
46
64
|
|
|
47
65
|
### Configuration
|
|
48
66
|
|
|
49
|
-
#### Update
|
|
67
|
+
#### Update Cypress config
|
|
50
68
|
|
|
51
|
-
`<rootDir>/cypress.
|
|
69
|
+
`<rootDir>/cypress.config.js`
|
|
52
70
|
|
|
53
71
|
```js
|
|
54
|
-
{
|
|
55
|
-
|
|
72
|
+
export default defineConfig({
|
|
73
|
+
|
|
74
|
+
env: {
|
|
56
75
|
"visualRegressionTracker": {
|
|
57
76
|
// URL where backend is running
|
|
58
77
|
// Required
|
|
@@ -83,7 +102,7 @@ module.exports = (on, config) => {
|
|
|
83
102
|
"ciBuildId": "SOME_UNIQUE_ID",
|
|
84
103
|
}
|
|
85
104
|
}
|
|
86
|
-
}
|
|
105
|
+
});
|
|
87
106
|
```
|
|
88
107
|
|
|
89
108
|
#### Or, as JSON config file `vrt.json`
|
|
@@ -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
|
+
});
|
package/dist/commands.d.ts
CHANGED
|
@@ -3,3 +3,12 @@ export declare const addVrtStopCommand: () => void;
|
|
|
3
3
|
export declare const addVrtTrackCommand: () => void;
|
|
4
4
|
export declare const addVrtTrackBufferCommand: () => void;
|
|
5
5
|
export declare const addVrtTrackBase64Command: () => void;
|
|
6
|
+
/**
|
|
7
|
+
* Add all Visual Tracker commands to Cypress namespace, so that these methods become available:
|
|
8
|
+
* * `cy.vrtStart();`
|
|
9
|
+
* * `cy.vrtStop();`
|
|
10
|
+
* * `cy.vrtTrack();`
|
|
11
|
+
* * `cy.vrtTrackBuffer();`
|
|
12
|
+
* * `cy.vrtTrackBase64();`
|
|
13
|
+
*/
|
|
14
|
+
export declare const addVrtCommands: () => void;
|
package/dist/commands.js
CHANGED
|
@@ -1,55 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addVrtTrackBase64Command = exports.addVrtTrackBufferCommand = exports.addVrtTrackCommand = exports.addVrtStopCommand = exports.addVrtStartCommand = void 0;
|
|
3
|
+
exports.addVrtCommands = exports.addVrtTrackBase64Command = exports.addVrtTrackBufferCommand = exports.addVrtTrackCommand = exports.addVrtStopCommand = exports.addVrtStartCommand = void 0;
|
|
4
4
|
/* global Cypress, cy */
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Cypress.Commands.add(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
const addVrtStartCommand = () => {
|
|
7
|
+
Cypress.Commands.add(utils_1.VRT_COMMAND_START, {
|
|
8
|
+
// optional: may start a chain, or use an existing chain: (dual command)
|
|
9
|
+
prevSubject: "optional",
|
|
10
|
+
}, () => {
|
|
11
|
+
cy.task(utils_1.VRT_TASK_START, {}, { log: false })
|
|
11
12
|
.then(utils_1.handleError)
|
|
12
|
-
.then(
|
|
13
|
+
.then(() => (0, utils_1.log)("Started"));
|
|
13
14
|
});
|
|
14
15
|
};
|
|
15
16
|
exports.addVrtStartCommand = addVrtStartCommand;
|
|
16
|
-
|
|
17
|
-
Cypress.Commands.add(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const addVrtStopCommand = () => {
|
|
18
|
+
Cypress.Commands.add(utils_1.VRT_COMMAND_STOP, {
|
|
19
|
+
// optional: may start a chain, or use an existing chain: (dual command)
|
|
20
|
+
prevSubject: "optional",
|
|
21
|
+
}, () => {
|
|
22
|
+
cy.task(utils_1.VRT_TASK_STOP, {}, { log: false })
|
|
21
23
|
.then(utils_1.handleError)
|
|
22
|
-
.then(
|
|
24
|
+
.then(() => (0, utils_1.log)("Stopped"));
|
|
23
25
|
});
|
|
24
26
|
};
|
|
25
27
|
exports.addVrtStopCommand = addVrtStopCommand;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
};
|
|
28
|
+
const addVrtTrackCommand = () => Cypress.Commands.add(utils_1.VRT_COMMAND_TRACK, {
|
|
29
|
+
// https://docs.cypress.io/api/cypress-api/custom-commands#Arguments
|
|
30
|
+
prevSubject: ["optional", "element", "window", "document"],
|
|
31
|
+
}, // @ts-ignore
|
|
32
|
+
(subject, name, options, errorCallback) => {
|
|
33
|
+
(0, utils_1.trackImage)(subject, name, options).then((result) => (0, utils_1.checkResult)(result, errorCallback));
|
|
34
|
+
});
|
|
35
35
|
exports.addVrtTrackCommand = addVrtTrackCommand;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return (0, utils_1.checkResult)(result);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
};
|
|
36
|
+
const addVrtTrackBufferCommand = () => Cypress.Commands.add(utils_1.VRT_COMMAND_TRACK_BUFFER, {
|
|
37
|
+
prevSubject: false,
|
|
38
|
+
}, (name, imageBuffer, options) => {
|
|
39
|
+
(0, utils_1.trackBuffer)(name, imageBuffer, options).then((result) => (0, utils_1.checkResult)(result));
|
|
40
|
+
});
|
|
45
41
|
exports.addVrtTrackBufferCommand = addVrtTrackBufferCommand;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return (0, utils_1.checkResult)(result);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
};
|
|
42
|
+
const addVrtTrackBase64Command = () => Cypress.Commands.add(utils_1.VRT_COMMAND_TRACK_BASE64, {
|
|
43
|
+
prevSubject: false,
|
|
44
|
+
}, (name, imageBase64, options) => {
|
|
45
|
+
(0, utils_1.trackBase64)(name, imageBase64, options).then((result) => (0, utils_1.checkResult)(result));
|
|
46
|
+
});
|
|
55
47
|
exports.addVrtTrackBase64Command = addVrtTrackBase64Command;
|
|
48
|
+
/**
|
|
49
|
+
* Add all Visual Tracker commands to Cypress namespace, so that these methods become available:
|
|
50
|
+
* * `cy.vrtStart();`
|
|
51
|
+
* * `cy.vrtStop();`
|
|
52
|
+
* * `cy.vrtTrack();`
|
|
53
|
+
* * `cy.vrtTrackBuffer();`
|
|
54
|
+
* * `cy.vrtTrackBase64();`
|
|
55
|
+
*/
|
|
56
|
+
const addVrtCommands = () => {
|
|
57
|
+
(0, exports.addVrtStartCommand)();
|
|
58
|
+
(0, exports.addVrtStopCommand)();
|
|
59
|
+
(0, exports.addVrtTrackCommand)();
|
|
60
|
+
(0, exports.addVrtTrackBufferCommand)();
|
|
61
|
+
(0, exports.addVrtTrackBase64Command)();
|
|
62
|
+
};
|
|
63
|
+
exports.addVrtCommands = addVrtCommands;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,47 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare namespace Cypress {
|
|
4
|
-
interface Chainable {
|
|
5
|
-
/**
|
|
6
|
-
* Validate image against baseline
|
|
7
|
-
* @param name Image identifier.
|
|
8
|
-
* @param options An object that contains one or more additional properties.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* cy.vrtTrack("name")
|
|
12
|
-
* cy.get("#id").vrtTrack("name", {
|
|
13
|
-
* os: "MacOS",
|
|
14
|
-
* device: "Cloud agent",
|
|
15
|
-
* customTags: "Cloud, DarkTheme, Auth",
|
|
16
|
-
* diffTollerancePercent: 1.23,
|
|
17
|
-
* ignoreAreas: [
|
|
18
|
-
* {x: 1, y: 2, width: 100, height: 200}
|
|
19
|
-
* ],
|
|
20
|
-
* retryLimit: 5,
|
|
21
|
-
* keepScreenshot: false,
|
|
22
|
-
* })
|
|
23
|
-
*/
|
|
24
|
-
vrtTrack(name: string, options?: Partial<Loggable & Timeoutable & ScreenshotOptions & TrackOptions & {
|
|
25
|
-
keepScreenshot?: boolean;
|
|
26
|
-
}>, errorCallback?: (err: string) => boolean): Chainable<null>;
|
|
27
|
-
vrtTrackBuffer(name: string, imageBuffer: Buffer, options?: Partial<Loggable & Timeoutable & ScreenshotOptions & TrackOptions>): Chainable<null>;
|
|
28
|
-
vrtTrackBase64(name: string, imageBase64: string, options?: Partial<Loggable & Timeoutable & ScreenshotOptions & TrackOptions>): Chainable<null>;
|
|
29
|
-
vrtStart(): null;
|
|
30
|
-
vrtStop(): null;
|
|
31
|
-
}
|
|
32
|
-
interface IgnoreArea {
|
|
33
|
-
x: number;
|
|
34
|
-
y: number;
|
|
35
|
-
width: number;
|
|
36
|
-
height: number;
|
|
37
|
-
}
|
|
38
|
-
interface TrackOptions {
|
|
39
|
-
viewport?: string;
|
|
40
|
-
os?: string;
|
|
41
|
-
device?: string;
|
|
42
|
-
customTags?: string;
|
|
43
|
-
diffTollerancePercent?: number;
|
|
44
|
-
ignoreAreas?: IgnoreArea[];
|
|
45
|
-
retryLimit?: number;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
export { addVrtStartCommand, addVrtStopCommand, addVrtTrackCommand, addVrtTrackBufferCommand, addVrtTrackBase64Command, addVrtCommands, } from "./commands";
|
|
2
|
+
export { addVisualRegressionTrackerPlugin } from "./plugin";
|
package/dist/index.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addVisualRegressionTrackerPlugin = exports.addVrtCommands = exports.addVrtTrackBase64Command = exports.addVrtTrackBufferCommand = exports.addVrtTrackCommand = exports.addVrtStopCommand = exports.addVrtStartCommand = void 0;
|
|
4
|
+
var commands_1 = require("./commands");
|
|
5
|
+
Object.defineProperty(exports, "addVrtStartCommand", { enumerable: true, get: function () { return commands_1.addVrtStartCommand; } });
|
|
6
|
+
Object.defineProperty(exports, "addVrtStopCommand", { enumerable: true, get: function () { return commands_1.addVrtStopCommand; } });
|
|
7
|
+
Object.defineProperty(exports, "addVrtTrackCommand", { enumerable: true, get: function () { return commands_1.addVrtTrackCommand; } });
|
|
8
|
+
Object.defineProperty(exports, "addVrtTrackBufferCommand", { enumerable: true, get: function () { return commands_1.addVrtTrackBufferCommand; } });
|
|
9
|
+
Object.defineProperty(exports, "addVrtTrackBase64Command", { enumerable: true, get: function () { return commands_1.addVrtTrackBase64Command; } });
|
|
10
|
+
Object.defineProperty(exports, "addVrtCommands", { enumerable: true, get: function () { return commands_1.addVrtCommands; } });
|
|
11
|
+
var plugin_1 = require("./plugin");
|
|
12
|
+
Object.defineProperty(exports, "addVisualRegressionTrackerPlugin", { enumerable: true, get: function () { return plugin_1.addVisualRegressionTrackerPlugin; } });
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
/**
|
|
3
|
+
* Register task event handlers for Cypress.
|
|
4
|
+
* @param on
|
|
5
|
+
* @param config
|
|
6
|
+
* @see https://docs.cypress.io/api/commands/task
|
|
7
|
+
*/
|
|
8
|
+
export declare function addVisualRegressionTrackerPlugin(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions): void;
|
package/dist/plugin.js
CHANGED
|
@@ -8,105 +8,63 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
12
|
exports.addVisualRegressionTrackerPlugin = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const sdk_js_1 = require("@visual-regression-tracker/sdk-js");
|
|
15
|
+
const utils_1 = require("./utils");
|
|
16
|
+
/**
|
|
17
|
+
* Register task event handlers for Cypress.
|
|
18
|
+
* @param on
|
|
19
|
+
* @param config
|
|
20
|
+
* @see https://docs.cypress.io/api/commands/task
|
|
21
|
+
*/
|
|
42
22
|
function addVisualRegressionTrackerPlugin(on, config) {
|
|
43
23
|
var _a;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
switch (_b.label) {
|
|
54
|
-
case 0:
|
|
55
|
-
_b.trys.push([0, 3, , 4]);
|
|
56
|
-
if (!!vrt["isStarted"]()) return [3 /*break*/, 2];
|
|
57
|
-
return [4 /*yield*/, vrt.start()];
|
|
58
|
-
case 1:
|
|
59
|
-
_b.sent();
|
|
60
|
-
_b.label = 2;
|
|
61
|
-
case 2: return [3 /*break*/, 4];
|
|
62
|
-
case 3:
|
|
63
|
-
err_1 = _b.sent();
|
|
64
|
-
return [2 /*return*/, (_a = err_1.message) !== null && _a !== void 0 ? _a : err_1];
|
|
65
|
-
case 4: return [2 /*return*/, null];
|
|
24
|
+
const vrtConfig = (_a = config === null || config === void 0 ? void 0 : config.env) === null || _a === void 0 ? void 0 : _a.visualRegressionTracker;
|
|
25
|
+
const vrt = new sdk_js_1.VisualRegressionTracker(vrtConfig);
|
|
26
|
+
on("task", {
|
|
27
|
+
// Start visual regression tracking unless it has already been started
|
|
28
|
+
[utils_1.VRT_TASK_START]: (props) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
var _b;
|
|
30
|
+
try {
|
|
31
|
+
if (!vrt[utils_1.VRT_IS_STARTED]()) {
|
|
32
|
+
yield vrt.start();
|
|
66
33
|
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
_b.sent();
|
|
80
|
-
_b.label = 2;
|
|
81
|
-
case 2: return [3 /*break*/, 4];
|
|
82
|
-
case 3:
|
|
83
|
-
err_2 = _b.sent();
|
|
84
|
-
return [2 /*return*/, (_a = err_2.message) !== null && _a !== void 0 ? _a : err_2];
|
|
85
|
-
case 4: return [2 /*return*/, null];
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
return (_b = err.message) !== null && _b !== void 0 ? _b : err;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}),
|
|
40
|
+
// Stop visual regression tracking if it was started
|
|
41
|
+
[utils_1.VRT_TASK_STOP]: (props) => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
var _c;
|
|
43
|
+
try {
|
|
44
|
+
if (vrt[utils_1.VRT_IS_STARTED]()) {
|
|
45
|
+
yield vrt.stop();
|
|
86
46
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return [7 /*endfinally*/];
|
|
106
|
-
case 4: return [2 /*return*/];
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
return (_c = err.message) !== null && _c !== void 0 ? _c : err;
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}),
|
|
53
|
+
// Track the given test case and optionally clean up the screenshot
|
|
54
|
+
[utils_1.VRT_TASK_TRACK]: (props) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
var _d;
|
|
56
|
+
try {
|
|
57
|
+
return yield vrt.track(props, props === null || props === void 0 ? void 0 : props.retryLimit);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
return (_d = err.message) !== null && _d !== void 0 ? _d : err;
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
if (!props.keepScreenshot && props.imagePath) {
|
|
64
|
+
(0, fs_1.unlinkSync)(props.imagePath);
|
|
107
65
|
}
|
|
108
|
-
}
|
|
109
|
-
})
|
|
110
|
-
|
|
66
|
+
}
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
111
69
|
}
|
|
112
70
|
exports.addVisualRegressionTrackerPlugin = addVisualRegressionTrackerPlugin;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
declare namespace Cypress {
|
|
4
|
+
interface Chainable {
|
|
5
|
+
/**
|
|
6
|
+
* Validate image against baseline
|
|
7
|
+
* @param name Image identifier.
|
|
8
|
+
* @param options An object that contains one or more additional properties.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* cy.vrtTrack("name")
|
|
12
|
+
* cy.get("#id").vrtTrack("name", {
|
|
13
|
+
* os: "MacOS",
|
|
14
|
+
* device: "Cloud agent",
|
|
15
|
+
* customTags: "Cloud, DarkTheme, Auth",
|
|
16
|
+
* diffTollerancePercent: 1.23,
|
|
17
|
+
* ignoreAreas: [
|
|
18
|
+
* {x: 1, y: 2, width: 100, height: 200}
|
|
19
|
+
* ],
|
|
20
|
+
* retryLimit: 5,
|
|
21
|
+
* keepScreenshot: false,
|
|
22
|
+
* })
|
|
23
|
+
*/
|
|
24
|
+
vrtTrack(name: string, options?: Partial<Loggable & Timeoutable & ScreenshotOptions & TrackOptions & {
|
|
25
|
+
keepScreenshot?: boolean;
|
|
26
|
+
}>, errorCallback?: (err: string) => boolean): Chainable<null>;
|
|
27
|
+
vrtTrackBuffer(name: string, imageBuffer: Buffer, options?: Partial<Loggable & Timeoutable & ScreenshotOptions & TrackOptions>): Chainable<null>;
|
|
28
|
+
vrtTrackBase64(name: string, imageBase64: string, options?: Partial<Loggable & Timeoutable & ScreenshotOptions & TrackOptions>): Chainable<null>;
|
|
29
|
+
vrtStart(): null;
|
|
30
|
+
vrtStop(): null;
|
|
31
|
+
}
|
|
32
|
+
interface IgnoreArea {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
width: number;
|
|
36
|
+
height: number;
|
|
37
|
+
}
|
|
38
|
+
interface TrackOptions {
|
|
39
|
+
viewport?: string;
|
|
40
|
+
os?: string;
|
|
41
|
+
device?: string;
|
|
42
|
+
customTags?: string;
|
|
43
|
+
diffTollerancePercent?: number;
|
|
44
|
+
ignoreAreas?: IgnoreArea[];
|
|
45
|
+
retryLimit?: number;
|
|
46
|
+
}
|
|
47
|
+
}
|
package/dist/types.js
ADDED
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/// <reference types="cypress" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { TestRunResponse } from "@visual-regression-tracker/sdk-js";
|
|
4
|
+
export declare const VRT_TASK_START = "VRT_START";
|
|
5
|
+
export declare const VRT_TASK_STOP = "VRT_STOP";
|
|
6
|
+
export declare const VRT_TASK_TRACK = "VRT_TRACK";
|
|
7
|
+
export declare const VRT_COMMAND_START = "vrtStart";
|
|
8
|
+
export declare const VRT_COMMAND_STOP = "vrtStop";
|
|
9
|
+
export declare const VRT_COMMAND_TRACK = "vrtTrack";
|
|
10
|
+
export declare const VRT_COMMAND_TRACK_BUFFER = "vrtTrackBuffer";
|
|
11
|
+
export declare const VRT_COMMAND_TRACK_BASE64 = "vrtTrackBase64";
|
|
12
|
+
export declare const VRT_IS_STARTED = "isStarted";
|
|
4
13
|
export declare const log: (message: string) => Cypress.Log;
|
|
5
14
|
export declare const handleError: (err: unknown) => void;
|
|
6
15
|
export declare const toTestRunDto: ({ name, pixelRatio, options, }: {
|
package/dist/utils.js
CHANGED
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* global Cypress, cy */
|
|
3
|
-
var __assign = (this && this.__assign) || function () {
|
|
4
|
-
__assign = Object.assign || function(t) {
|
|
5
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
-
s = arguments[i];
|
|
7
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
-
t[p] = s[p];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
return __assign.apply(this, arguments);
|
|
13
|
-
};
|
|
14
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.trackBase64 = exports.trackBuffer = exports.trackImage = exports.checkResult = exports.toTestRunDto = exports.handleError = exports.log = void 0;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
4
|
+
exports.trackBase64 = exports.trackBuffer = exports.trackImage = exports.checkResult = exports.toTestRunDto = exports.handleError = exports.log = exports.VRT_IS_STARTED = exports.VRT_COMMAND_TRACK_BASE64 = exports.VRT_COMMAND_TRACK_BUFFER = exports.VRT_COMMAND_TRACK = exports.VRT_COMMAND_STOP = exports.VRT_COMMAND_START = exports.VRT_TASK_TRACK = exports.VRT_TASK_STOP = exports.VRT_TASK_START = void 0;
|
|
5
|
+
// Task names
|
|
6
|
+
exports.VRT_TASK_START = "VRT_START";
|
|
7
|
+
exports.VRT_TASK_STOP = "VRT_STOP";
|
|
8
|
+
exports.VRT_TASK_TRACK = "VRT_TRACK";
|
|
9
|
+
// Command names
|
|
10
|
+
exports.VRT_COMMAND_START = "vrtStart";
|
|
11
|
+
exports.VRT_COMMAND_STOP = "vrtStop";
|
|
12
|
+
exports.VRT_COMMAND_TRACK = "vrtTrack";
|
|
13
|
+
exports.VRT_COMMAND_TRACK_BUFFER = "vrtTrackBuffer";
|
|
14
|
+
exports.VRT_COMMAND_TRACK_BASE64 = "vrtTrackBase64";
|
|
15
|
+
// Private method name in sdk-js, FIXME: public?
|
|
16
|
+
exports.VRT_IS_STARTED = "isStarted";
|
|
17
|
+
const log = (message) => Cypress.log({
|
|
18
|
+
name: "Visual Regression Tracker",
|
|
19
|
+
displayName: "VRT",
|
|
20
|
+
message,
|
|
21
|
+
});
|
|
23
22
|
exports.log = log;
|
|
24
|
-
|
|
23
|
+
const handleError = (err) => {
|
|
25
24
|
if (err) {
|
|
26
25
|
throw new Error(err);
|
|
27
26
|
}
|
|
28
27
|
};
|
|
29
28
|
exports.handleError = handleError;
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
var name = _a.name, _c = _a.pixelRatio, pixelRatio = _c === void 0 ? 1 : _c, options = _a.options;
|
|
29
|
+
const toTestRunDto = ({ name, pixelRatio = 1, options, }) => {
|
|
30
|
+
var _a;
|
|
33
31
|
return ({
|
|
34
|
-
name
|
|
32
|
+
name,
|
|
35
33
|
browser: Cypress.browser.name,
|
|
36
|
-
viewport: (
|
|
34
|
+
viewport: (_a = options === null || options === void 0 ? void 0 : options.viewport) !== null && _a !== void 0 ? _a : `${Cypress.config("viewportWidth") * pixelRatio}x${Cypress.config("viewportHeight") * pixelRatio}`,
|
|
37
35
|
os: options === null || options === void 0 ? void 0 : options.os,
|
|
38
36
|
device: options === null || options === void 0 ? void 0 : options.device,
|
|
39
37
|
customTags: options === null || options === void 0 ? void 0 : options.customTags,
|
|
@@ -45,7 +43,7 @@ var toTestRunDto = function (_a) {
|
|
|
45
43
|
});
|
|
46
44
|
};
|
|
47
45
|
exports.toTestRunDto = toTestRunDto;
|
|
48
|
-
|
|
46
|
+
const checkResult = (result, errorCallback) => {
|
|
49
47
|
if (typeof result === "string") {
|
|
50
48
|
// . this is an error message
|
|
51
49
|
if (errorCallback) {
|
|
@@ -57,29 +55,29 @@ var checkResult = function (result, errorCallback) {
|
|
|
57
55
|
}
|
|
58
56
|
};
|
|
59
57
|
exports.checkResult = checkResult;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
const trackImage = (subject, name, options) => {
|
|
59
|
+
let imagePath;
|
|
60
|
+
let pixelRatio;
|
|
61
|
+
const target = subject ? cy.wrap(subject) : cy;
|
|
62
|
+
// cy.screenshot() return Type is always Chainable<null>
|
|
63
|
+
// https://github.com/cypress-io/cypress/issues/21277
|
|
64
64
|
return target
|
|
65
|
-
.screenshot(name,
|
|
65
|
+
.screenshot(name, Object.assign(Object.assign({}, options), { onAfterScreenshot: ($el, props) => {
|
|
66
66
|
imagePath = props.path;
|
|
67
67
|
pixelRatio = props.pixelRatio;
|
|
68
68
|
return options === null || options === void 0 ? void 0 : options.onAfterScreenshot;
|
|
69
|
-
} }))
|
|
70
|
-
.then(
|
|
71
|
-
.then(
|
|
72
|
-
return cy.task("VRT_TRACK", __assign(__assign({}, (0, exports.toTestRunDto)({ name: name, pixelRatio: pixelRatio, options: options })), { imagePath: imagePath }), { log: false });
|
|
73
|
-
});
|
|
69
|
+
} })) // @ts-ignore
|
|
70
|
+
.then(() => (0, exports.log)(`tracking ${name}`))
|
|
71
|
+
.then(() => cy.task(exports.VRT_TASK_TRACK, Object.assign(Object.assign({}, (0, exports.toTestRunDto)({ name, pixelRatio, options })), { imagePath }), { log: false }));
|
|
74
72
|
};
|
|
75
73
|
exports.trackImage = trackImage;
|
|
76
|
-
|
|
77
|
-
(0, exports.log)(
|
|
78
|
-
return cy.task(
|
|
74
|
+
const trackBuffer = (name, imageBuffer, options) => {
|
|
75
|
+
(0, exports.log)(`tracking ${name}`);
|
|
76
|
+
return cy.task(exports.VRT_TASK_TRACK, Object.assign(Object.assign({}, (0, exports.toTestRunDto)({ name, options })), { imageBuffer }), { log: false });
|
|
79
77
|
};
|
|
80
78
|
exports.trackBuffer = trackBuffer;
|
|
81
|
-
|
|
82
|
-
(0, exports.log)(
|
|
83
|
-
return cy.task(
|
|
79
|
+
const trackBase64 = (name, imageBase64, options) => {
|
|
80
|
+
(0, exports.log)(`tracking ${name}`);
|
|
81
|
+
return cy.task(exports.VRT_TASK_TRACK, Object.assign(Object.assign({}, (0, exports.toTestRunDto)({ name, options })), { imageBase64 }), { log: false });
|
|
84
82
|
};
|
|
85
83
|
exports.trackBase64 = trackBase64;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visual-regression-tracker/agent-cypress",
|
|
3
|
-
"version": "5.
|
|
4
|
-
"description": "Visual Regression Tracker integration plugin",
|
|
3
|
+
"version": "5.7.0",
|
|
4
|
+
"description": "Visual Regression Tracker integration plugin for Cypress",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/
|
|
6
|
+
"types": "dist/",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
9
|
"semantic-release": "semantic-release"
|
|
@@ -18,22 +18,28 @@
|
|
|
18
18
|
"visual-regression-tracker"
|
|
19
19
|
],
|
|
20
20
|
"author": "Pavel Strunkin <pashidlos@gmail.com>",
|
|
21
|
-
"license": "
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
22
|
"bugs": {
|
|
23
23
|
"url": "https://github.com/Visual-Regression-Tracker/agent-cypress/issues"
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://github.com/Visual-Regression-Tracker/agent-cypress#readme",
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=16.16.0"
|
|
28
|
+
},
|
|
26
29
|
"dependencies": {
|
|
27
|
-
"@visual-regression-tracker/sdk-js": "5.
|
|
30
|
+
"@visual-regression-tracker/sdk-js": "5.7.0"
|
|
28
31
|
},
|
|
29
32
|
"devDependencies": {
|
|
30
|
-
"@types/jest": "^
|
|
31
|
-
"@types/node": "^
|
|
32
|
-
"cypress": "^
|
|
33
|
-
"jest": "^
|
|
34
|
-
"semantic-release": "^
|
|
35
|
-
"ts-jest": "^
|
|
36
|
-
"typescript": "^
|
|
33
|
+
"@types/jest": "^29.5.3",
|
|
34
|
+
"@types/node": "^16.18.38",
|
|
35
|
+
"cypress": "^12.17.3",
|
|
36
|
+
"jest": "^29.6.1",
|
|
37
|
+
"semantic-release": "^21.0.7",
|
|
38
|
+
"ts-jest": "^29.1.1",
|
|
39
|
+
"typescript": "^5.1.6"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"cypress": ">=12.17.1"
|
|
37
43
|
},
|
|
38
44
|
"publishConfig": {
|
|
39
45
|
"access": "public"
|