Skip to content

Commit d711fc4

Browse files
feat: add optional keepScreenshot option to vrtTrack (#189)
* feat: add optional keepScreenshot option to vrtTrack * refactor: add keepScreenshot option to test
1 parent c8f4775 commit d711fc4

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ cy.vrtTrack("Whole page with additional options", {
136136
diffTollerancePercent: 1,
137137
ignoreAreas: [{ x: 1, y: 2, width: 100, height: 200 }],
138138
retryLimit: 2,
139+
keepScreenshot: false, // Keep screenshot local copy, false by default
139140
});
140141
```
141142

cypress/integration/example.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ context("Visual Regression Tracker", () => {
3434
device: "Cloud agent",
3535
customTags: "Cloud, DarkTheme, Auth",
3636
diffTollerancePercent: 0,
37+
keepScreenshot: true,
3738
ignoreAreas: [
3839
{
3940
x: 0,

lib/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ declare namespace Cypress {
1515
* ignoreAreas: [
1616
* {x: 1, y: 2, width: 100, height: 200}
1717
* ],
18-
* retryLimit: 5
18+
* retryLimit: 5,
19+
* keepScreenshot: false,
1920
* })
2021
*/
2122
vrtTrack(
2223
name: string,
2324
options?: Partial<
24-
Loggable & Timeoutable & ScreenshotOptions & TrackOptions
25+
Loggable &
26+
Timeoutable &
27+
ScreenshotOptions &
28+
TrackOptions & { keepScreenshot?: boolean }
2529
>
2630
): Chainable<null>;
2731

lib/plugin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ export function addVisualRegressionTrackerPlugin(on, config) {
4040

4141
const result = await vrt["submitTestRunMultipart"](data);
4242

43-
unlinkSync(props.imagePath);
43+
if (!props.keepScreenshot) {
44+
unlinkSync(props.imagePath);
45+
}
4446
return result;
4547
},
4648
["VRT_TRACK_BUFFER_MULTIPART"]: async (props) => {

lib/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const toTestRunDto = ({
4141
customTags: options?.customTags,
4242
diffTollerancePercent: options?.diffTollerancePercent,
4343
ignoreAreas: options?.ignoreAreas,
44+
keepScreenshot: options?.keepScreenshot,
4445
});
4546

4647
export const trackWithRetry = (

0 commit comments

Comments
 (0)