@visual-regression-tracker/agent-cypress 5.4.0 → 5.5.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/README.md CHANGED
@@ -121,8 +121,6 @@ cy.vrtStart();
121
121
 
122
122
  ### Assert
123
123
 
124
- All `options` from `screenshot` command are also supported [more details](https://docs.cypress.io/api/commands/screenshot.html#Arguments)
125
-
126
124
  ```js
127
125
  cy.vrtTrack("Whole page with default params");
128
126
 
@@ -137,13 +135,24 @@ cy.vrtTrack("Whole page with additional options", {
137
135
  ignoreAreas: [{ x: 1, y: 2, width: 100, height: 200 }],
138
136
  retryLimit: 2,
139
137
  keepScreenshot: false, // Keep screenshot local copy, false by default
138
+ }, (err)=>{
139
+ console.log('Screenshot has diff with baseline', err);
140
+ return true; // Skip failing test
140
141
  });
141
142
  ```
143
+ ##### options (optional)
144
+
145
+ Allows to set options for taking screenshot. All `options` from `screenshot` command are also supported [more details](https://docs.cypress.io/api/commands/screenshot.html#Arguments)
142
146
 
143
147
  Viewport is taken from `Cypress.config()`, if option is not set
144
148
 
145
149
  Browser is taken from `Cypress.browser.name`
146
150
 
151
+ ##### errorCallbak (optional)
152
+ Allows you to define a callback that receives the error for custom side-effects.
153
+
154
+ Also allows to override assertion policy. When callback returns `true` this acts similar to `enableSoftAssertions` option in config, but allows to enable soft assertion only for one specific screenshot.
155
+
147
156
  ### Teadown
148
157
 
149
158
  ```js
package/dist/commands.js CHANGED
@@ -26,8 +26,8 @@ exports.addVrtStopCommand = addVrtStopCommand;
26
26
  var addVrtTrackCommand = function () {
27
27
  return Cypress.Commands.add("vrtTrack", {
28
28
  prevSubject: ["optional", "element", "window", "document"],
29
- }, function (subject, name, options) {
30
- (0, utils_1.trackWithRetry)(function () { return (0, utils_1.trackImage)(subject, name, options); }, function (result) { return (0, utils_1.shouldStopRetry)(result); }, function (result) { return (0, utils_1.checkResult)(result); }, options === null || options === void 0 ? void 0 : options.retryLimit);
29
+ }, function (subject, name, options, errorCallback) {
30
+ (0, utils_1.trackWithRetry)(function () { return (0, utils_1.trackImage)(subject, name, options); }, function (result) { return (0, utils_1.shouldStopRetry)(result); }, function (result) { return (0, utils_1.checkResult)(result, errorCallback); }, options === null || options === void 0 ? void 0 : options.retryLimit);
31
31
  });
32
32
  };
33
33
  exports.addVrtTrackCommand = addVrtTrackCommand;
package/dist/index.d.ts CHANGED
@@ -23,7 +23,7 @@ declare namespace Cypress {
23
23
  */
24
24
  vrtTrack(name: string, options?: Partial<Loggable & Timeoutable & ScreenshotOptions & TrackOptions & {
25
25
  keepScreenshot?: boolean;
26
- }>): Chainable<null>;
26
+ }>, errorCallback?: (err: string) => boolean): Chainable<null>;
27
27
  vrtTrackBuffer(name: string, imageBuffer: Buffer, options?: Partial<Loggable & Timeoutable & ScreenshotOptions & TrackOptions>): Chainable<null>;
28
28
  vrtTrackBase64(name: string, imageBase64: string, options?: Partial<Loggable & Timeoutable & ScreenshotOptions & TrackOptions>): Chainable<null>;
29
29
  vrtStart(): null;
package/dist/utils.d.ts CHANGED
@@ -19,7 +19,7 @@ export declare const toTestRunDto: ({ name, pixelRatio, options, }: {
19
19
  keepScreenshot: any;
20
20
  };
21
21
  export declare const trackWithRetry: (trackFn: () => Cypress.Chainable<TestRunResponse>, shouldStopFn: (result: TestRunResponse) => boolean, onStopFn: (result: TestRunResponse) => Cypress.Chainable<unknown>, retryLimit?: number) => unknown;
22
- export declare const checkResult: (result: TestRunResponse) => Cypress.Chainable<unknown>;
22
+ export declare const checkResult: (result: TestRunResponse, errorCallback?: ((err: string) => boolean) | undefined) => Cypress.Chainable<unknown>;
23
23
  export declare const shouldStopRetry: (result: TestRunResponse) => boolean;
24
24
  export declare const trackImage: (subject: any, name: string, options: any) => Cypress.Chainable<TestRunResponse>;
25
25
  export declare const trackBuffer: (name: string, imageBuffer: Buffer, options: any) => Cypress.Chainable<TestRunResponse>;
package/dist/utils.js CHANGED
@@ -56,9 +56,14 @@ var trackWithRetry = function (trackFn, shouldStopFn, onStopFn, retryLimit) {
56
56
  });
57
57
  };
58
58
  exports.trackWithRetry = trackWithRetry;
59
- var checkResult = function (result) {
60
- return cy.task("VRT_PROCESS_ERROR_RESULT", result, { log: false }).then(exports.handleError);
61
- };
59
+ var checkResult = function (result, errorCallback) { return cy.task("VRT_PROCESS_ERROR_RESULT", result, { log: false }).then(function (err) {
60
+ if (err && errorCallback) {
61
+ if (errorCallback(err)) {
62
+ return;
63
+ }
64
+ }
65
+ (0, exports.handleError)(err);
66
+ }); };
62
67
  exports.checkResult = checkResult;
63
68
  var shouldStopRetry = function (result) {
64
69
  return (result === null || result === void 0 ? void 0 : result.status) !== sdk_js_1.TestStatus.unresolved;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visual-regression-tracker/agent-cypress",
3
- "version": "5.4.0",
3
+ "version": "5.5.0",
4
4
  "description": "Visual Regression Tracker integration plugin",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",