From c8d8a1f95dfe29c05bbbd24ef901de24552f6e66 Mon Sep 17 00:00:00 2001 From: tnelms1 Date: Fri, 19 Jan 2024 10:26:46 -0700 Subject: [PATCH] SBVT-2286: Fixing the stitching issue (#222) * SBVT-2286: formatting changes * SBVT-2286: formatting changes * SBVT-2286: if testing with chrome we default to old screenshot version * SBVT-2286: final copy * SBVT-2286: updating deps --- commands.js | 504 +++++++++++++++++++++++++++++------------ package-lock.json | 214 ++++++++--------- package.json | 8 +- plugin.js | 7 + test/package-lock.json | 21 +- test/package.json | 2 +- 6 files changed, 489 insertions(+), 267 deletions(-) diff --git a/commands.js b/commands.js index 169d365..28cb90d 100644 --- a/commands.js +++ b/commands.js @@ -73,7 +73,10 @@ let takeScreenshot = (element, name, modifiedOptions, win) => { if (typeof modifiedOptions.lazyload === 'number' && modifiedOptions.lazyload <= 10000 && modifiedOptions.lazyload >= 0) { const defaultDelay = 1500; // if the user lazyloads above 375ms it will be X * 4 const pageLoadDelay = modifiedOptions.lazyload * 4 > defaultDelay ? modifiedOptions.lazyload * 4 : defaultDelay; - cy.task('logger', {type: 'info', message: `Adding a delay to let the page load of ${pageLoadDelay / 1000} seconds`}); + cy.task('logger', { + type: 'info', + message: `Adding a delay to let the page load of ${pageLoadDelay / 1000} seconds` + }); cy.wait(pageLoadDelay); } @@ -85,7 +88,10 @@ let takeScreenshot = (element, name, modifiedOptions, win) => { win.eval(`delete window.sbvt`); //clear the window.sbvt so subsequent runs don't have previous ignoredElements if (Array.isArray(modifiedOptions.ignoreElements)) { // ignoreElements function - cy.task('logger', {type: 'info', message: `JSON.stringify(modifiedOptions.ignoreElements): ${JSON.stringify(modifiedOptions.ignoreElements)}`}); + cy.task('logger', { + type: 'info', + message: `JSON.stringify(modifiedOptions.ignoreElements): ${JSON.stringify(modifiedOptions.ignoreElements)}` + }); // Make sure each element is found on the dom, will throw error here if element not found modifiedOptions.ignoreElements.forEach(element => { @@ -105,7 +111,6 @@ let takeScreenshot = (element, name, modifiedOptions, win) => { if (vtConfFile.fail) { console.log('The sbvtScreenshot() has failed'); cy.task('logger', {type: 'trace', message: `sbvtCapture() has failed`}); //I dont think this should be printed out each screenshot - } else if (element) { // Begin Cypress element capture method cy.task('logger', {type: 'debug', message: `Beginning element cy.screenshot('${name}')`}); @@ -141,7 +146,10 @@ let takeScreenshot = (element, name, modifiedOptions, win) => { if (numScrolls * viewportHeight < offsetHeight || numScrolls * viewportHeight - viewportHeight > offsetHeight) { // This checks if the users website is fully loaded or if there are issues with some of the numbers that will return an issue when we go to stitch or crop the images together //TODO eventually add a wait here and rerun the above data on the webpage - cy.task('logger', {type: 'info', message: `numScrolls * viewportHeight <= offsetHeight: ${numScrolls * viewportHeight} >= ${offsetHeight} ——> ${numScrolls * viewportHeight >= offsetHeight}`}); + cy.task('logger', { + type: 'info', + message: `numScrolls * viewportHeight <= offsetHeight: ${numScrolls * viewportHeight} >= ${offsetHeight} ——> ${numScrolls * viewportHeight >= offsetHeight}` + }); cy.task('logger', { type: 'info', message: `numScrolls * viewportHeight - viewportHeight >= offsetHeight: ${numScrolls * viewportHeight - viewportHeight} <= ${offsetHeight} ——> ${numScrolls * viewportHeight - viewportHeight <= offsetHeight}` @@ -156,132 +164,305 @@ let takeScreenshot = (element, name, modifiedOptions, win) => { // Generate the array needed for a for-loop in Cypress let scrollArray = Array.from({length: numScrolls}, (v, k) => k + 1); - if (numScrolls <= 1) { - // Check if the webpage is not scrollable - if (modifiedOptions.lazyload) { - // Warn if the webpage is not scrollable, and user is trying to lazyload - cy.task('logger', {type: `warn`, message: `the webpage is not scrollable, not able to lazyload "${imageName}", taking regular screenshot`}); - } else { - // No need to throw warning if not lazyload - cy.task('logger', {type: `info`, message: `the webpage is not scrollable for image: "${imageName}", taking regular screenshot`}); - } - } else if (modifiedOptions.scrollMethod === "JS_SCROLL") { - // If the user wants to use the old JS_SCROLL method - cy.task('logger', {type: 'info', message: `Passed in 'scrollMethod= "JS_SCROLL"' taking regular screenshot`}); + if (numScrolls !== 1 && Cypress.browser.name === 'chrome' && modifiedOptions.scrollMethod !== "JS_SCROLL") { + let testScreenshotProps + cy.screenshot( + name, + {capture: 'viewport', + onAfterScreenshot($el, props) { + testScreenshotProps = props; + }}, + ).then(() => { + cy.task('deleteImage', {path: testScreenshotProps.path}) + if (testScreenshotProps.dimensions.height !== viewportHeight) { + // throw new Error(('this will be bad stitching')) + cy.task('logger', {type: 'info', message: `starting cypress's default full-page screenshot chrome because of the mismatch`}); + if (runFreezePage) { + // freezePageResult = win.eval(toolkitScripts.freezePage) + win.eval(toolkitScripts.freezePage); // don't overwrite for now. in freeze page test #1 it defaults to here because it is a single page webpage, maybe allow the other method to take single page screenshots + cy.task('logger', {type: 'debug', message: `running freezePage in the default fullpage.`}); + } + + // Old/default Cypress screenshot / JS_SCROLL screenshot + cy.screenshot( + name, + modifiedOptions, + ).then(() => { + if (vtConfFile.debug) cy.task('copy', {path: picProps.path, imageName, imageType}); + + // Reset browser to initial state + win.eval(`window.scrollTo(${initialPageState.scrollX}, ${initialPageState.scrollY})`); + win.eval(`document.body.style.transform='${initialPageState.transform}'`); + // ensureScrolledToTop(win) //this creates issues, but this is the JS_SCROLL method + captureDom(win); + + win.eval(`document.documentElement.style.overflow='${initialPageState.documentOverflow}'`); + cy.task('logger', {type: 'trace', message: `After default fullpage cy.screenshot('${name}')`}); + + // Read the new image base64 to blob to be sent to AWS + readImageAndBase64ToBlob(); + }); + } else { + // throw new Error(('this will be fine')) //todo remove the error thrown + // No errors so far + if ((modifiedOptions.lazyload !== undefined) && (modifiedOptions.lazyload > 10000 || modifiedOptions.lazyload < 0 || isNaN(modifiedOptions.lazyload))) { + // User gave us a bad wait time + cy.task('logger', { + type: 'warn', + message: `invalid wait time value for lazyload, must be a number & between 0 - 10,000 milliseconds` + }); + throw new Error("invalid wait time value for lazyload, must be a number & between 0 - 10,000 milliseconds"); + } else if (typeof modifiedOptions.lazyload === 'number') { // make sure lazyload is not given + // Begin the lazyload method - no errors + cy.task('logger', { + type: 'debug', + message: `starting lazy load script with wait time: ${modifiedOptions.lazyload / 1000} seconds per scroll` + }); + cy.wrap(scrollArray).each(index => { + cy.task('logger', { + type: 'trace', + message: `scrolling ${index}/${numScrolls}, waiting: ${modifiedOptions.lazyload / 1000} seconds per scroll` + }); + cy.scrollTo(0, viewportHeight * index); + cy.wait(modifiedOptions.lazyload); + }); + cy.scrollTo(0, 0); + cy.wait(1000); + if (runFreezePage) { + cy.task('logger', {type: 'debug', message: `running freezePage in the lazyload function.`}); + freezePageResult = win.eval(toolkitScripts.freezePage); + } + // Recalculate this in case the webpage changed dimensions during lazy loading + ({numScrolls, offsetHeight, viewportHeight, viewportWidth} = getWebpageDimension(win)) + scrollArray = Array.from({length: numScrolls}, (v, k) => k + 1); + } else { + if (runFreezePage) { + cy.task('logger', {type: 'debug', message: `running freezePage, no lazyload.`}); + freezePageResult = win.eval(toolkitScripts.freezePage); + } + } + + + // scroll down one viewport at a time and take a viewport screenshot + cy.wrap(scrollArray).each(index => { + cy.task('logger', { + type: 'trace', + message: `capturing ${index}/${numScrolls} viewport for the fullpage capture` + }); + cy.screenshot(`tmp/${imageName}/${index - 1}`, { + capture: "viewport", + overwrite: true, + onAfterScreenshot($el, props) { + fullpageData = { + tmpPath: props.path, + url: $el[0].baseURI + }; + } + }).then(() => { + win.eval(`document.body.style.transform="translateY(${(index) * -100}vh)"`); + + if (numScrolls === index) { + // This if checks if the for-loop is done... + cy.task('logger', { + type: 'debug', + message: `finished taking viewports, now going to the stitchImages task` + }); + // Jump into stitchImages task/method to stitch all the viewports together + cy.task('stitchImages', { + imageName, + imagesPath: fullpageData.tmpPath, + pageHeight: offsetHeight, + viewportWidth, + viewportHeight + }) + .then((imageData) => { + if (imageData === "error") { //should not get here, error should be handled earlier + cy.task('logger', { + type: 'error', + message: `Error with lazyload on ${imageName}, no screenshot taken` + }); + return; + } + picProps = { + path: imageData.path, + dimensions: { + height: imageData.height, + width: imageData.width + } + }; + + // Reset browser to initial state + cy.task('logger', { + type: 'trace', + message: `After fullpage cy.screenshot('${name}')` + }); + win.eval(`window.scrollTo(${initialPageState.scrollX}, ${initialPageState.scrollY})`); + win.eval(`document.body.style.transform='${initialPageState.transform}'`); + ensureScrolledToTop(win) + captureDom(win); + win.eval(`document.documentElement.style.overflow='${initialPageState.documentOverflow}'`); + + // Read the new image base64 to blob to be sent to AWS + readImageAndBase64ToBlob(); + }); + } + }); + }); + return; + } + }); } else { - // No errors so far - if ((modifiedOptions.lazyload !== undefined) && (modifiedOptions.lazyload > 10000 || modifiedOptions.lazyload < 0 || isNaN(modifiedOptions.lazyload))) { - // User gave us a bad wait time - cy.task('logger', {type: 'warn', message: `invalid wait time value for lazyload, must be a number & between 0 - 10,000 milliseconds`}); - throw new Error("invalid wait time value for lazyload, must be a number & between 0 - 10,000 milliseconds"); - } else if (typeof modifiedOptions.lazyload === 'number') { // make sure lazyload is not given - // Begin the lazyload method - no errors - cy.task('logger', {type: 'debug', message: `starting lazy load script with wait time: ${modifiedOptions.lazyload / 1000} seconds per scroll`}); - cy.wrap(scrollArray).each(index => { - cy.task('logger', {type: 'trace', message: `scrolling ${index}/${numScrolls}, waiting: ${modifiedOptions.lazyload / 1000} seconds per scroll`}); - cy.scrollTo(0, viewportHeight * index); - cy.wait(modifiedOptions.lazyload); - }); - cy.scrollTo(0, 0); - cy.wait(1000); - if (runFreezePage) { - cy.task('logger', {type: 'debug', message: `running freezePage in the lazyload function.`}); - freezePageResult = win.eval(toolkitScripts.freezePage); + if (numScrolls <= 1) { + // Check if the webpage is not scrollable + if (modifiedOptions.lazyload) { + // Warn if the webpage is not scrollable, and user is trying to lazyload + cy.task('logger', { + type: `warn`, + message: `the webpage is not scrollable, not able to lazyload "${imageName}", taking regular screenshot` + }); + } else { + // No need to throw warning if not lazyload + cy.task('logger', { + type: `info`, + message: `the webpage is not scrollable for image: "${imageName}", taking regular screenshot` + }); } - // Recalculate this in case the webpage changed dimensions during lazy loading - ({numScrolls, offsetHeight, viewportHeight, viewportWidth} = getWebpageDimension(win)) - scrollArray = Array.from({length: numScrolls}, (v, k) => k + 1); + } else if (modifiedOptions.scrollMethod === "JS_SCROLL") { + // If the user wants to use the old JS_SCROLL method + cy.task('logger', { + type: 'info', + message: `Passed in 'scrollMethod= "JS_SCROLL"' taking regular screenshot` + }); } else { - if (runFreezePage) { - cy.task('logger', {type: 'debug', message: `running freezePage, no lazyload.`}); - freezePageResult = win.eval(toolkitScripts.freezePage); + // No errors so far + if ((modifiedOptions.lazyload !== undefined) && (modifiedOptions.lazyload > 10000 || modifiedOptions.lazyload < 0 || isNaN(modifiedOptions.lazyload))) { + // User gave us a bad wait time + cy.task('logger', { + type: 'warn', + message: `invalid wait time value for lazyload, must be a number & between 0 - 10,000 milliseconds` + }); + throw new Error("invalid wait time value for lazyload, must be a number & between 0 - 10,000 milliseconds"); + } else if (typeof modifiedOptions.lazyload === 'number') { // make sure lazyload is not given + // Begin the lazyload method - no errors + cy.task('logger', { + type: 'debug', + message: `starting lazy load script with wait time: ${modifiedOptions.lazyload / 1000} seconds per scroll` + }); + cy.wrap(scrollArray).each(index => { + cy.task('logger', { + type: 'trace', + message: `scrolling ${index}/${numScrolls}, waiting: ${modifiedOptions.lazyload / 1000} seconds per scroll` + }); + cy.scrollTo(0, viewportHeight * index); + cy.wait(modifiedOptions.lazyload); + }); + cy.scrollTo(0, 0); + cy.wait(1000); + if (runFreezePage) { + cy.task('logger', {type: 'debug', message: `running freezePage in the lazyload function.`}); + freezePageResult = win.eval(toolkitScripts.freezePage); + } + // Recalculate this in case the webpage changed dimensions during lazy loading + ({numScrolls, offsetHeight, viewportHeight, viewportWidth} = getWebpageDimension(win)) + scrollArray = Array.from({length: numScrolls}, (v, k) => k + 1); + } else { + if (runFreezePage) { + cy.task('logger', {type: 'debug', message: `running freezePage, no lazyload.`}); + freezePageResult = win.eval(toolkitScripts.freezePage); + } } + // scroll down one viewport at a time and take a viewport screenshot + cy.wrap(scrollArray).each(index => { + cy.task('logger', { + type: 'trace', + message: `capturing ${index}/${numScrolls} viewport for the fullpage capture` + }); + cy.screenshot(`tmp/${imageName}/${index - 1}`, { + capture: "viewport", + overwrite: true, + onAfterScreenshot($el, props) { + fullpageData = { + tmpPath: props.path, + url: $el[0].baseURI + }; + } + }).then(() => { + win.eval(`document.body.style.transform="translateY(${(index) * -100}vh)"`); + if (numScrolls === index) { + // This if checks if the for-loop is done... + cy.task('logger', { + type: 'debug', + message: `finished taking viewports, now going to the stitchImages task` + }); + // Jump into stitchImages task/method to stitch all the viewports together + cy.task('stitchImages', { + imageName, + imagesPath: fullpageData.tmpPath, + pageHeight: offsetHeight, + viewportWidth, + viewportHeight + }) + .then((imageData) => { + if (imageData === "error") { //should not get here, error should be handled earlier + cy.task('logger', { + type: 'error', + message: `Error with lazyload on ${imageName}, no screenshot taken` + }); + return; + } + picProps = { + path: imageData.path, + dimensions: { + height: imageData.height, + width: imageData.width + } + }; + // Reset browser to initial state + cy.task('logger', { + type: 'trace', + message: `After fullpage cy.screenshot('${name}')` + }); + win.eval(`window.scrollTo(${initialPageState.scrollX}, ${initialPageState.scrollY})`); + win.eval(`document.body.style.transform='${initialPageState.transform}'`); + ensureScrolledToTop(win) + captureDom(win); + win.eval(`document.documentElement.style.overflow='${initialPageState.documentOverflow}'`); + + // Read the new image base64 to blob to be sent to AWS + readImageAndBase64ToBlob(); + }); + } + }); + }); + return; + } + cy.task('logger', {type: 'info', message: `starting cypress's default fullpage screenshot`}); + if (runFreezePage) { + // freezePageResult = win.eval(toolkitScripts.freezePage) + win.eval(toolkitScripts.freezePage); // don't overwrite for now. in freeze page test #1 it defaults to here because it is a single page webpage, maybe allow the other method to take single page screenshots + cy.task('logger', {type: 'debug', message: `running freezePage in the default fullpage.`}); } + // Old/default Cypress screenshot / JS_SCROLL screenshot + cy.screenshot( + name, + modifiedOptions, + ).then(() => { + if (vtConfFile.debug) cy.task('copy', {path: picProps.path, imageName, imageType}); + // Reset browser to initial state + win.eval(`window.scrollTo(${initialPageState.scrollX}, ${initialPageState.scrollY})`); + win.eval(`document.body.style.transform='${initialPageState.transform}'`); + // ensureScrolledToTop(win) //this creates issues, but this is the JS_SCROLL method + captureDom(win); - // scroll down one viewport at a time and take a viewport screenshot - cy.wrap(scrollArray).each(index => { - cy.task('logger', {type: 'trace', message: `capturing ${index}/${numScrolls} viewport for the fullpage capture`}); - cy.screenshot(`tmp/${imageName}/${index - 1}`, { - capture: "viewport", - overwrite: true, - onAfterScreenshot($el, props) { - fullpageData = { - tmpPath: props.path, - url: $el[0].baseURI - }; - } - }).then(() => { - win.eval(`document.body.style.transform="translateY(${(index) * -100}vh)"`); - - if (numScrolls === index) { - // This if checks if the for-loop is done... - cy.task('logger', {type: 'debug', message: `finished taking viewports, now going to the stitchImages task`}); - - // Jump into stitchImages task/method to stitch all the viewports together - cy.task('stitchImages', { - imageName, - imagesPath: fullpageData.tmpPath, - pageHeight: offsetHeight, - viewportWidth, - viewportHeight - }) - .then((imageData) => { - if (imageData === "error") { //should not get here, error should be handled earlier - cy.task('logger', {type: 'error', message: `Error with lazyload on ${imageName}, no screenshot taken`}); - return; - } - picProps = { - path: imageData.path, - dimensions: { - height: imageData.height, - width: imageData.width - } - }; + win.eval(`document.documentElement.style.overflow='${initialPageState.documentOverflow}'`); + cy.task('logger', {type: 'trace', message: `After default fullpage cy.screenshot('${name}')`}); - // Reset browser to initial state - cy.task('logger', {type: 'trace', message: `After fullpage cy.screenshot('${name}')`}); - win.eval(`window.scrollTo(${initialPageState.scrollX}, ${initialPageState.scrollY})`); - win.eval(`document.body.style.transform='${initialPageState.transform}'`); - ensureScrolledToTop(win) - captureDom(win); - win.eval(`document.documentElement.style.overflow='${initialPageState.documentOverflow}'`); - - // Read the new image base64 to blob to be sent to AWS - readImageAndBase64ToBlob(); - }); - } - }); + // Read the new image base64 to blob to be sent to AWS + readImageAndBase64ToBlob(); }); - return; } - cy.task('logger', {type: 'info', message: `starting cypress's default fullpage screenshot`}); - if (runFreezePage) { - // freezePageResult = win.eval(toolkitScripts.freezePage) - win.eval(toolkitScripts.freezePage); // don't overwrite for now. in freeze page test #1 it defaults to here because it is a single page webpage, maybe allow the other method to take single page screenshots - cy.task('logger', {type: 'debug', message: `running freezePage in the default fullpage.`}); - } - - // Old/default Cypress screenshot / JS_SCROLL screenshot - cy.screenshot( - name, - modifiedOptions, - ).then(() => { - if (vtConfFile.debug) cy.task('copy', {path: picProps.path, imageName, imageType}); - - // Reset browser to initial state - win.eval(`window.scrollTo(${initialPageState.scrollX}, ${initialPageState.scrollY})`); - win.eval(`document.body.style.transform='${initialPageState.transform}'`); - // ensureScrolledToTop(win) //this creates issues, but this is the JS_SCROLL method - captureDom(win); - - win.eval(`document.documentElement.style.overflow='${initialPageState.documentOverflow}'`); - cy.task('logger', {type: 'trace', message: `After default fullpage cy.screenshot('${name}')`}); - - // Read the new image base64 to blob to be sent to AWS - readImageAndBase64ToBlob(); - }); } if (!vtConfFile.fail) { // Return the scroll bar after the sbvtCapture has completed @@ -357,12 +538,12 @@ let uploadDomToS3 = async (url, imageId) => { body: { domCaptured: true }, - headers: {Authorization : `Bearer ${vtConfFile.projectToken}`}, + headers: {Authorization: `Bearer ${vtConfFile.projectToken}`}, }) .then((patchResponse) => { cy.task('logger', {type: 'info', message: `after s3 dom upload, image PATCH response: `}) cy.task('logger', {type: 'info', message: patchResponse}) - }) + }) } }); }; @@ -384,12 +565,15 @@ let uploadImageToS3 = async (url, imageId) => { }; const s3ErrorPatch = (response, imageId) => { cy.task('logger', {type: 'error', message: `Failed S3 PUT status: ${response.status}`}) - cy.task('logger', {type: 'info', message: `Going to PATCH the image at url: ${vtConfFile.url}/api/v1/projects/${vtConfFile.projectId}/testruns/${vtConfFile.testRunId}/images/${imageId}`}) + cy.task('logger', { + type: 'info', + message: `Going to PATCH the image at url: ${vtConfFile.url}/api/v1/projects/${vtConfFile.projectId}/testruns/${vtConfFile.testRunId}/images/${imageId}` + }) cy.request({ method: "PATCH", url: `${vtConfFile.url}/api/v1/projects/${vtConfFile.projectId}/testruns/${vtConfFile.testRunId}/images/${imageId}`, failOnStatusCode: false, - headers: {Authorization : `Bearer ${vtConfFile.projectToken}`}, + headers: {Authorization: `Bearer ${vtConfFile.projectToken}`}, body: { errorMessage: JSON.stringify(response) } @@ -406,16 +590,28 @@ let readImageAndBase64ToBlob = () => { }; let checkForChangedDimensions = () => { if (!picProps.pixelRatio) { //calculate pixel ratio - cy.task('logger', {type: "info", message: `calculated pixel ratio is: ${picProps.dimensions.width / dom.viewport.width}`}); + cy.task('logger', { + type: "info", + message: `calculated pixel ratio is: ${picProps.dimensions.width / dom.viewport.width}` + }); picProps.pixelRatio = picProps.dimensions.width / dom.viewport.width } if (picProps.pixelRatio && Cypress.browser.isHeadless && dom.viewport.width * picProps.pixelRatio !== picProps.dimensions.width) { - cy.task('logger', {type: "fatal", message: `${dom.viewport.width*picProps.pixelRatio} !== ${picProps.dimensions.width} ----> dom.viewport.width*picProps.pixelRatio !== picProps.dimensions.width`}); + cy.task('logger', { + type: "fatal", + message: `${dom.viewport.width * picProps.pixelRatio} !== ${picProps.dimensions.width} ----> dom.viewport.width*picProps.pixelRatio !== picProps.dimensions.width` + }); // cy.task('logger', {type: "fatal", message: `${dom.viewport.width}*${picProps.pixelRatio} !== ${picProps.dimensions.width} ----> dom.viewport.width*picProps.pixelRatio !== picProps.dimensions.width`}); cy.task('logger', {type: "warn", message: `It looks like you are trying to change the viewport`}); - cy.task('logger', {type: "warn", message: `This issue with Cypress makes thee captured image look disproportional`}); + cy.task('logger', { + type: "warn", + message: `This issue with Cypress makes thee captured image look disproportional` + }); cy.task('logger', {type: "warn", message: `Check this Cypress documentation for a solution: `}); - cy.task('logger', {type: "warn", message: `\t\thttps://docs.cypress.io/api/plugins/browser-launch-api#Set-screen-size-when-running-headless`}); + cy.task('logger', { + type: "warn", + message: `\t\thttps://docs.cypress.io/api/plugins/browser-launch-api#Set-screen-size-when-running-headless` + }); } }; let captureDom = (win) => { @@ -423,7 +619,10 @@ let captureDom = (win) => { dom.screenshotType = imageType.toLowerCase() if (Array.isArray(dom.ignoredElementsData) && dom.ignoredElementsData.length) { - cy.task('logger', {type: "info", message: `returned dom.ignoredElementsData: ${JSON.stringify(dom.ignoredElementsData)}`}); + cy.task('logger', { + type: "info", + message: `returned dom.ignoredElementsData: ${JSON.stringify(dom.ignoredElementsData)}` + }); } const megabytes = ((new TextEncoder().encode(JSON.stringify(dom)).byteLength) / 1048576); @@ -438,21 +637,27 @@ let captureDom = (win) => { cy.writeFile(`./${vtConfFile.debug}/${imageName}-${imageType}/${imageName}.json`, dom); } }; -let ensureScrolledToTop = (win) =>{ +let ensureScrolledToTop = (win) => { let tries = 0; let scrollOffset = win.eval(`window.scrollY`); - while (scrollOffset !== 0 && tries < 40){ + while (scrollOffset !== 0 && tries < 40) { tries++; - cy.task('logger', {type: 'warn', message: `Page not scrolled to the top. Scroll offset is: ${scrollOffset}. Trying to scroll to the top again and waiting 250ms. Try #: ${tries}`}); - cy.scrollTo(0,0); + cy.task('logger', { + type: 'warn', + message: `Page not scrolled to the top. Scroll offset is: ${scrollOffset}. Trying to scroll to the top again and waiting 250ms. Try #: ${tries}` + }); + cy.scrollTo(0, 0); win.eval(`window.scrollTo(0, 0);`) cy.wait(250); scrollOffset = win.eval(`window.scrollY`); //check and update the scrolled position again } - if (tries < 40 && scrollOffset === 0){ + if (tries < 40 && scrollOffset === 0) { cy.task('logger', {type: 'info', message: `Scroll offset is: ${scrollOffset}, after ${tries} tries`}); - }else{ - cy.task('logger', {type: 'error', message: `Couldn't scroll to the top of page after ${tries} tries. Scroll offset positon stuck at: ${scrollOffset}.`}); + } else { + cy.task('logger', { + type: 'error', + message: `Couldn't scroll to the top of page after ${tries} tries. Scroll offset positon stuck at: ${scrollOffset}.` + }); throw new Error(`Couldn't scroll to the top of page after ${tries} tries. Scroll offset positon stuck at: ${scrollOffset}.`); } } @@ -484,16 +689,19 @@ let getComparisonMode = (comparisonMode, sensitivity) => { } }; -let getWebpageDimension = (win)=>{ - // Run some JS commands on the user's browser to get details about the webpage - let numScrolls = win.eval("Math.ceil(Math.max(window.document.body.offsetHeight, window.document.body.scrollHeight, window.document.documentElement.offsetHeight, window.document.documentElement.scrollHeight) / window.innerHeight)"); - let offsetHeight = win.eval("Math.max(window.document.body.offsetHeight,window.document.body.scrollHeight, window.document.documentElement.offsetHeight, window.document.documentElement.scrollHeight)"); - let viewportHeight = win.eval("window.innerHeight"); - let viewportWidth = win.eval("window.innerWidth"); +let getWebpageDimension = (win) => { + // Run some JS commands on the user's browser to get details about the webpage + let numScrolls = win.eval("Math.ceil(Math.max(window.document.body.offsetHeight, window.document.body.scrollHeight, window.document.documentElement.offsetHeight, window.document.documentElement.scrollHeight) / window.innerHeight)"); + let offsetHeight = win.eval("Math.max(window.document.body.offsetHeight,window.document.body.scrollHeight, window.document.documentElement.offsetHeight, window.document.documentElement.scrollHeight)"); + let viewportHeight = win.eval("window.innerHeight"); + let viewportWidth = win.eval("window.innerWidth"); - cy.task('logger', {type: 'info', message: `numScrolls: ${numScrolls}, viewportHeight: ${viewportHeight}, offsetHeight(page height): ${offsetHeight}`}); + cy.task('logger', { + type: 'info', + message: `numScrolls: ${numScrolls}, viewportHeight: ${viewportHeight}, offsetHeight(page height): ${offsetHeight}` + }); - return {numScrolls, offsetHeight, viewportHeight, viewportWidth} + return {numScrolls, offsetHeight, viewportHeight, viewportWidth} } Cypress.Commands.add('sbvtGetTestRunResult', () => { @@ -501,7 +709,10 @@ Cypress.Commands.add('sbvtGetTestRunResult', () => { return cy.task('getTestRunResult') .then((response) => { if (response.error) { - cy.task('logger', {type: 'error', message: `There was an issue with cy.sbvtGetTestRunResult() — ${response.error}`}); + cy.task('logger', { + type: 'error', + message: `There was an issue with cy.sbvtGetTestRunResult() — ${response.error}` + }); cy.wait(700); //without this, the logger doesn't get printed } else { delete response.data.aggregate.other; @@ -514,7 +725,10 @@ Cypress.Commands.add('sbvtPrintReport', () => { cy.task('getTestRunResult') .then(response => { if (response.error) { - cy.task('logger', {type: 'error', message: `There was an issue with cy.sbvtPrintReport() — ${response.error}`}); + cy.task('logger', { + type: 'error', + message: `There was an issue with cy.sbvtPrintReport() — ${response.error}` + }); cy.wait(700); //without this, the logger doesn't get printed } else { cy.task('printReport', response.data); diff --git a/package-lock.json b/package-lock.json index e92b864..344f580 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,22 +1,22 @@ { "name": "@smartbear/visualtest-cypress", - "version": "1.9.0", + "version": "1.9.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@smartbear/visualtest-cypress", - "version": "1.9.0", + "version": "1.9.1", "license": "ISC", "dependencies": { - "axios": "^1.6.3", + "axios": "^1.6.5", "chalk": "^4.1.2", - "dotenv": "^16.3.1", + "dotenv": "^16.3.2", "fs-extra": "^11.2.0", "pino": "^8.17.2", "pino-pretty": "^10.3.1", "semver": "^7.5.4", - "sharp": "^0.33.1", + "sharp": "^0.33.2", "uuid": "^9.0.1" }, "bin": { @@ -39,9 +39,9 @@ } }, "node_modules/@emnapi/runtime": { - "version": "0.44.0", - "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-0.44.0.tgz", - "integrity": "sha512-ZX/etZEZw8DR7zAB1eVQT40lNo0jeqpb6dCgOvctB6FIQ5PoXfMuNY8+ayQfu8tNQbAB8gQWSSJupR8NxeiZXw==", + "version": "0.45.0", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-0.45.0.tgz", + "integrity": "sha512-Txumi3td7J4A/xTTwlssKieHKTGl3j4A1tglBx72auZ49YK7ePY6XZricgIg9mnZT4xPfA+UPCUdnhRuEFDL+w==", "optional": true, "dependencies": { "tslib": "^2.4.0" @@ -54,9 +54,9 @@ "dev": true }, "node_modules/@img/sharp-darwin-arm64": { - "version": "0.33.1", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.1.tgz", - "integrity": "sha512-esr2BZ1x0bo+wl7Gx2hjssYhjrhUsD88VQulI0FrG8/otRQUOxLWHMBd1Y1qo2Gfg2KUvXNpT0ASnV9BzJCexw==", + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.2.tgz", + "integrity": "sha512-itHBs1rPmsmGF9p4qRe++CzCgd+kFYktnsoR1sbIAfsRMrJZau0Tt1AH9KVnufc2/tU02Gf6Ibujx+15qRE03w==", "cpu": [ "arm64" ], @@ -75,13 +75,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-darwin-arm64": "1.0.0" + "@img/sharp-libvips-darwin-arm64": "1.0.1" } }, "node_modules/@img/sharp-darwin-x64": { - "version": "0.33.1", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.1.tgz", - "integrity": "sha512-YrnuB3bXuWdG+hJlXtq7C73lF8ampkhU3tMxg5Hh+E7ikxbUVOU9nlNtVTloDXz6pRHt2y2oKJq7DY/yt+UXYw==", + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.2.tgz", + "integrity": "sha512-/rK/69Rrp9x5kaWBjVN07KixZanRr+W1OiyKdXcbjQD6KbW+obaTeBBtLUAtbBsnlTTmWthw99xqoOS7SsySDg==", "cpu": [ "x64" ], @@ -100,13 +100,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-darwin-x64": "1.0.0" + "@img/sharp-libvips-darwin-x64": "1.0.1" } }, "node_modules/@img/sharp-libvips-darwin-arm64": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.0.tgz", - "integrity": "sha512-VzYd6OwnUR81sInf3alj1wiokY50DjsHz5bvfnsFpxs5tqQxESoHtJO6xyksDs3RIkyhMWq2FufXo6GNSU9BMw==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.1.tgz", + "integrity": "sha512-kQyrSNd6lmBV7O0BUiyu/OEw9yeNGFbQhbxswS1i6rMDwBBSX+e+rPzu3S+MwAiGU3HdLze3PanQ4Xkfemgzcw==", "cpu": [ "arm64" ], @@ -125,9 +125,9 @@ } }, "node_modules/@img/sharp-libvips-darwin-x64": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.0.tgz", - "integrity": "sha512-dD9OznTlHD6aovRswaPNEy8dKtSAmNo4++tO7uuR4o5VxbVAOoEQ1uSmN4iFAdQneTHws1lkTZeiXPrcCkh6IA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.1.tgz", + "integrity": "sha512-eVU/JYLPVjhhrd8Tk6gosl5pVlvsqiFlt50wotCvdkFGf+mDNBJxMh+bvav+Wt3EBnNZWq8Sp2I7XfSjm8siog==", "cpu": [ "x64" ], @@ -146,9 +146,9 @@ } }, "node_modules/@img/sharp-libvips-linux-arm": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.0.tgz", - "integrity": "sha512-VwgD2eEikDJUk09Mn9Dzi1OW2OJFRQK+XlBTkUNmAWPrtj8Ly0yq05DFgu1VCMx2/DqCGQVi5A1dM9hTmxf3uw==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.1.tgz", + "integrity": "sha512-FtdMvR4R99FTsD53IA3LxYGghQ82t3yt0ZQ93WMZ2xV3dqrb0E8zq4VHaTOuLEAuA83oDawHV3fd+BsAPadHIQ==", "cpu": [ "arm" ], @@ -167,9 +167,9 @@ } }, "node_modules/@img/sharp-libvips-linux-arm64": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.0.tgz", - "integrity": "sha512-xTYThiqEZEZc0PRU90yVtM3KE7lw1bKdnDQ9kCTHWbqWyHOe4NpPOtMGy27YnN51q0J5dqRrvicfPbALIOeAZA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.1.tgz", + "integrity": "sha512-bnGG+MJjdX70mAQcSLxgeJco11G+MxTz+ebxlz8Y3dxyeb3Nkl7LgLI0mXupoO+u1wRNx/iRj5yHtzA4sde1yA==", "cpu": [ "arm64" ], @@ -188,9 +188,9 @@ } }, "node_modules/@img/sharp-libvips-linux-s390x": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.0.0.tgz", - "integrity": "sha512-o9E46WWBC6JsBlwU4QyU9578G77HBDT1NInd+aERfxeOPbk0qBZHgoDsQmA2v9TbqJRWzoBPx1aLOhprBMgPjw==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.0.1.tgz", + "integrity": "sha512-3+rzfAR1YpMOeA2zZNp+aYEzGNWK4zF3+sdMxuCS3ey9HhDbJ66w6hDSHDMoap32DueFwhhs3vwooAB2MaK4XQ==", "cpu": [ "s390x" ], @@ -209,9 +209,9 @@ } }, "node_modules/@img/sharp-libvips-linux-x64": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.0.tgz", - "integrity": "sha512-naldaJy4hSVhWBgEjfdBY85CAa4UO+W1nx6a1sWStHZ7EUfNiuBTTN2KUYT5dH1+p/xij1t2QSXfCiFJoC5S/Q==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.1.tgz", + "integrity": "sha512-3NR1mxFsaSgMMzz1bAnnKbSAI+lHXVTqAHgc1bgzjHuXjo4hlscpUxc0vFSAPKI3yuzdzcZOkq7nDPrP2F8Jgw==", "cpu": [ "x64" ], @@ -230,9 +230,9 @@ } }, "node_modules/@img/sharp-libvips-linuxmusl-arm64": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.0.tgz", - "integrity": "sha512-OdorplCyvmSAPsoJLldtLh3nLxRrkAAAOHsGWGDYfN0kh730gifK+UZb3dWORRa6EusNqCTjfXV4GxvgJ/nPDQ==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.1.tgz", + "integrity": "sha512-5aBRcjHDG/T6jwC3Edl3lP8nl9U2Yo8+oTl5drd1dh9Z1EBfzUKAJFUDTDisDjUwc7N4AjnPGfCA3jl3hY8uDg==", "cpu": [ "arm64" ], @@ -251,9 +251,9 @@ } }, "node_modules/@img/sharp-libvips-linuxmusl-x64": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.0.tgz", - "integrity": "sha512-FW8iK6rJrg+X2jKD0Ajhjv6y74lToIBEvkZhl42nZt563FfxkCYacrXZtd+q/sRQDypQLzY5WdLkVTbJoPyqNg==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.1.tgz", + "integrity": "sha512-dcT7inI9DBFK6ovfeWRe3hG30h51cBAP5JXlZfx6pzc/Mnf9HFCQDLtYf4MCBjxaaTfjCCjkBxcy3XzOAo5txw==", "cpu": [ "x64" ], @@ -272,9 +272,9 @@ } }, "node_modules/@img/sharp-linux-arm": { - "version": "0.33.1", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.33.1.tgz", - "integrity": "sha512-Ii4X1vnzzI4j0+cucsrYA5ctrzU9ciXERfJR633S2r39CiD8npqH2GMj63uFZRCFt3E687IenAdbwIpQOJ5BNA==", + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.33.2.tgz", + "integrity": "sha512-Fndk/4Zq3vAc4G/qyfXASbS3HBZbKrlnKZLEJzPLrXoJuipFNNwTes71+Ki1hwYW5lch26niRYoZFAtZVf3EGA==", "cpu": [ "arm" ], @@ -293,13 +293,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-arm": "1.0.0" + "@img/sharp-libvips-linux-arm": "1.0.1" } }, "node_modules/@img/sharp-linux-arm64": { - "version": "0.33.1", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.1.tgz", - "integrity": "sha512-59B5GRO2d5N3tIfeGHAbJps7cLpuWEQv/8ySd9109ohQ3kzyCACENkFVAnGPX00HwPTQcaBNF7HQYEfZyZUFfw==", + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.2.tgz", + "integrity": "sha512-pz0NNo882vVfqJ0yNInuG9YH71smP4gRSdeL09ukC2YLE6ZyZePAlWKEHgAzJGTiOh8Qkaov6mMIMlEhmLdKew==", "cpu": [ "arm64" ], @@ -318,13 +318,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-arm64": "1.0.0" + "@img/sharp-libvips-linux-arm64": "1.0.1" } }, "node_modules/@img/sharp-linux-s390x": { - "version": "0.33.1", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.33.1.tgz", - "integrity": "sha512-tRGrb2pHnFUXpOAj84orYNxHADBDIr0J7rrjwQrTNMQMWA4zy3StKmMvwsI7u3dEZcgwuMMooIIGWEWOjnmG8A==", + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.33.2.tgz", + "integrity": "sha512-MBoInDXDppMfhSzbMmOQtGfloVAflS2rP1qPcUIiITMi36Mm5YR7r0ASND99razjQUpHTzjrU1flO76hKvP5RA==", "cpu": [ "s390x" ], @@ -343,13 +343,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-s390x": "1.0.0" + "@img/sharp-libvips-linux-s390x": "1.0.1" } }, "node_modules/@img/sharp-linux-x64": { - "version": "0.33.1", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.1.tgz", - "integrity": "sha512-4y8osC0cAc1TRpy02yn5omBeloZZwS62fPZ0WUAYQiLhSFSpWJfY/gMrzKzLcHB9ulUV6ExFiu2elMaixKDbeg==", + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.2.tgz", + "integrity": "sha512-xUT82H5IbXewKkeF5aiooajoO1tQV4PnKfS/OZtb5DDdxS/FCI/uXTVZ35GQ97RZXsycojz/AJ0asoz6p2/H/A==", "cpu": [ "x64" ], @@ -368,13 +368,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-x64": "1.0.0" + "@img/sharp-libvips-linux-x64": "1.0.1" } }, "node_modules/@img/sharp-linuxmusl-arm64": { - "version": "0.33.1", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.1.tgz", - "integrity": "sha512-D3lV6clkqIKUizNS8K6pkuCKNGmWoKlBGh5p0sLO2jQERzbakhu4bVX1Gz+RS4vTZBprKlWaf+/Rdp3ni2jLfA==", + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.2.tgz", + "integrity": "sha512-F+0z8JCu/UnMzg8IYW1TMeiViIWBVg7IWP6nE0p5S5EPQxlLd76c8jYemG21X99UzFwgkRo5yz2DS+zbrnxZeA==", "cpu": [ "arm64" ], @@ -393,13 +393,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-arm64": "1.0.0" + "@img/sharp-libvips-linuxmusl-arm64": "1.0.1" } }, "node_modules/@img/sharp-linuxmusl-x64": { - "version": "0.33.1", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.1.tgz", - "integrity": "sha512-LOGKNu5w8uu1evVqUAUKTix2sQu1XDRIYbsi5Q0c/SrXhvJ4QyOx+GaajxmOg5PZSsSnCYPSmhjHHsRBx06/wQ==", + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.2.tgz", + "integrity": "sha512-+ZLE3SQmSL+Fn1gmSaM8uFusW5Y3J9VOf+wMGNnTtJUMUxFhv+P4UPaYEYT8tqnyYVaOVGgMN/zsOxn9pSsO2A==", "cpu": [ "x64" ], @@ -418,19 +418,19 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-x64": "1.0.0" + "@img/sharp-libvips-linuxmusl-x64": "1.0.1" } }, "node_modules/@img/sharp-wasm32": { - "version": "0.33.1", - "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.33.1.tgz", - "integrity": "sha512-vWI/sA+0p+92DLkpAMb5T6I8dg4z2vzCUnp8yvxHlwBpzN8CIcO3xlSXrLltSvK6iMsVMNswAv+ub77rsf25lA==", + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.33.2.tgz", + "integrity": "sha512-fLbTaESVKuQcpm8ffgBD7jLb/CQLcATju/jxtTXR1XCLwbOQt+OL5zPHSDMmp2JZIeq82e18yE0Vv7zh6+6BfQ==", "cpu": [ "wasm32" ], "optional": true, "dependencies": { - "@emnapi/runtime": "^0.44.0" + "@emnapi/runtime": "^0.45.0" }, "engines": { "node": "^18.17.0 || ^20.3.0 || >=21.0.0", @@ -443,9 +443,9 @@ } }, "node_modules/@img/sharp-win32-ia32": { - "version": "0.33.1", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.33.1.tgz", - "integrity": "sha512-/xhYkylsKL05R+NXGJc9xr2Tuw6WIVl2lubFJaFYfW4/MQ4J+dgjIo/T4qjNRizrqs/szF/lC9a5+updmY9jaQ==", + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.33.2.tgz", + "integrity": "sha512-okBpql96hIGuZ4lN3+nsAjGeggxKm7hIRu9zyec0lnfB8E7Z6p95BuRZzDDXZOl2e8UmR4RhYt631i7mfmKU8g==", "cpu": [ "ia32" ], @@ -464,9 +464,9 @@ } }, "node_modules/@img/sharp-win32-x64": { - "version": "0.33.1", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.1.tgz", - "integrity": "sha512-XaM69X0n6kTEsp9tVYYLhXdg7Qj32vYJlAKRutxUsm1UlgQNx6BOhHwZPwukCGXBU2+tH87ip2eV1I/E8MQnZg==", + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.2.tgz", + "integrity": "sha512-E4magOks77DK47FwHUIGH0RYWSgRBfGdK56kIHSVeB9uIS4pPFr4N2kIVsXdQQo4LzOsENKV5KAhRlRL7eMAdg==", "cpu": [ "x64" ], @@ -1090,11 +1090,11 @@ } }, "node_modules/axios": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.3.tgz", - "integrity": "sha512-fWyNdeawGam70jXSVlKl+SUNVcL6j6W79CuSIPfi6HnDUmSCH6gyUys/HrqHeA/wU0Az41rRgean494d0Jb+ww==", + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.5.tgz", + "integrity": "sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg==", "dependencies": { - "follow-redirects": "^1.15.0", + "follow-redirects": "^1.15.4", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } @@ -1665,9 +1665,9 @@ } }, "node_modules/dotenv": { - "version": "16.3.1", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", - "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", + "version": "16.3.2", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.2.tgz", + "integrity": "sha512-HTlk5nmhkm8F6JcdXvHIzaorzCoziNQT9mGxLPVXW8wJF1TiGSL60ZGB4gHWabHOaMmWmhvk2/lPHfnBiT78AQ==", "engines": { "node": ">=12" }, @@ -1832,9 +1832,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", - "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", + "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", "funding": [ { "type": "individual", @@ -4231,9 +4231,9 @@ "dev": true }, "node_modules/sharp": { - "version": "0.33.1", - "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.33.1.tgz", - "integrity": "sha512-iAYUnOdTqqZDb3QjMneBKINTllCJDZ3em6WaWy7NPECM4aHncvqHRm0v0bN9nqJxMiwamv5KIdauJ6lUzKDpTQ==", + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.33.2.tgz", + "integrity": "sha512-WlYOPyyPDiiM07j/UO+E720ju6gtNtHjEGg5vovUk1Lgxyjm2LFO+37Nt/UI3MMh2l6hxTWQWi7qk3cXJTutcQ==", "hasInstallScript": true, "dependencies": { "color": "^4.2.3", @@ -4241,32 +4241,32 @@ "semver": "^7.5.4" }, "engines": { - "libvips": ">=8.15.0", + "libvips": ">=8.15.1", "node": "^18.17.0 || ^20.3.0 || >=21.0.0" }, "funding": { "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-darwin-arm64": "0.33.1", - "@img/sharp-darwin-x64": "0.33.1", - "@img/sharp-libvips-darwin-arm64": "1.0.0", - "@img/sharp-libvips-darwin-x64": "1.0.0", - "@img/sharp-libvips-linux-arm": "1.0.0", - "@img/sharp-libvips-linux-arm64": "1.0.0", - "@img/sharp-libvips-linux-s390x": "1.0.0", - "@img/sharp-libvips-linux-x64": "1.0.0", - "@img/sharp-libvips-linuxmusl-arm64": "1.0.0", - "@img/sharp-libvips-linuxmusl-x64": "1.0.0", - "@img/sharp-linux-arm": "0.33.1", - "@img/sharp-linux-arm64": "0.33.1", - "@img/sharp-linux-s390x": "0.33.1", - "@img/sharp-linux-x64": "0.33.1", - "@img/sharp-linuxmusl-arm64": "0.33.1", - "@img/sharp-linuxmusl-x64": "0.33.1", - "@img/sharp-wasm32": "0.33.1", - "@img/sharp-win32-ia32": "0.33.1", - "@img/sharp-win32-x64": "0.33.1" + "@img/sharp-darwin-arm64": "0.33.2", + "@img/sharp-darwin-x64": "0.33.2", + "@img/sharp-libvips-darwin-arm64": "1.0.1", + "@img/sharp-libvips-darwin-x64": "1.0.1", + "@img/sharp-libvips-linux-arm": "1.0.1", + "@img/sharp-libvips-linux-arm64": "1.0.1", + "@img/sharp-libvips-linux-s390x": "1.0.1", + "@img/sharp-libvips-linux-x64": "1.0.1", + "@img/sharp-libvips-linuxmusl-arm64": "1.0.1", + "@img/sharp-libvips-linuxmusl-x64": "1.0.1", + "@img/sharp-linux-arm": "0.33.2", + "@img/sharp-linux-arm64": "0.33.2", + "@img/sharp-linux-s390x": "0.33.2", + "@img/sharp-linux-x64": "0.33.2", + "@img/sharp-linuxmusl-arm64": "0.33.2", + "@img/sharp-linuxmusl-x64": "0.33.2", + "@img/sharp-wasm32": "0.33.2", + "@img/sharp-win32-ia32": "0.33.2", + "@img/sharp-win32-x64": "0.33.2" } }, "node_modules/shebang-command": { diff --git a/package.json b/package.json index 6bdf7d4..36e505a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@smartbear/visualtest-cypress", - "version": "1.9.0", + "version": "1.9.1", "description": "Cypress Plugin for SmartBear VisualTest via JavaScript", "author": "Trevor Nelms", "main": "index.js", @@ -12,14 +12,14 @@ "publish-npm-public": "scripts/publish-NPM-public.sh" }, "dependencies": { - "axios": "^1.6.3", + "axios": "^1.6.5", "chalk": "^4.1.2", - "dotenv": "^16.3.1", + "dotenv": "^16.3.2", "fs-extra": "^11.2.0", "pino": "^8.17.2", "pino-pretty": "^10.3.1", "semver": "^7.5.4", - "sharp": "^0.33.1", + "sharp": "^0.33.2", "uuid": "^9.0.1" }, "bin": { diff --git a/plugin.js b/plugin.js index 61117c1..f23e706 100644 --- a/plugin.js +++ b/plugin.js @@ -439,6 +439,13 @@ function makeGlobalRunHooks() { if (configFile.debug) await fs.copy(path, `${debugFolderPath}/${imageName}-${imageType}/${imageName}.png`); //copy the final image to debug folder return null; }, + async deleteImage({path}) { + if (configFile.debug) { + logger.info(`deleting: ${path}`); + } + fs.unlinkSync(path); + return null; + }, async logger({type, message}) { //this task is for printing logs to node console from the custom command //todo this still isnt waiting to print the logger before returning type === 'fatal' ? await logger.fatal(message) : diff --git a/test/package-lock.json b/test/package-lock.json index bd80ae6..5ac18f7 100644 --- a/test/package-lock.json +++ b/test/package-lock.json @@ -10,24 +10,24 @@ "license": "ISC", "dependencies": { "@smartbear/visualtest-cypress": "file:..", - "cypress": "^13.6.2", + "cypress": "^13.6.3", "mochawesome": "^7.1.3", "mochawesome-merge": "^4.3.0" } }, "..": { "name": "@smartbear/visualtest-cypress", - "version": "1.9.0", + "version": "1.9.1", "license": "ISC", "dependencies": { - "axios": "^1.6.3", + "axios": "^1.6.5", "chalk": "^4.1.2", - "dotenv": "^16.3.1", + "dotenv": "^16.3.2", "fs-extra": "^11.2.0", "pino": "^8.17.2", "pino-pretty": "^10.3.1", "semver": "^7.5.4", - "sharp": "^0.33.1", + "sharp": "^0.33.2", "uuid": "^9.0.1" }, "bin": { @@ -101,6 +101,7 @@ "version": "18.19.3", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.3.tgz", "integrity": "sha512-k5fggr14DwAytoA/t8rPrIz++lXK7/DqckthCmoZOKNsEbJkId4Z//BqgApXBUGrGddrigYa1oqheo/7YmW4rg==", + "optional": true, "dependencies": { "undici-types": "~5.26.4" } @@ -626,14 +627,13 @@ } }, "node_modules/cypress": { - "version": "13.6.2", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.6.2.tgz", - "integrity": "sha512-TW3bGdPU4BrfvMQYv1z3oMqj71YI4AlgJgnrycicmPZAXtvywVFZW9DAToshO65D97rCWfG/kqMFsYB6Kp91gQ==", + "version": "13.6.3", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.6.3.tgz", + "integrity": "sha512-d/pZvgwjAyZsoyJ3FOsJT5lDsqnxQ/clMqnNc++rkHjbkkiF2h9s0JsZSyyH4QXhVFW3zPFg82jD25roFLOdZA==", "hasInstallScript": true, "dependencies": { "@cypress/request": "^3.0.0", "@cypress/xvfb": "^1.2.4", - "@types/node": "^18.17.5", "@types/sinonjs__fake-timers": "8.1.1", "@types/sizzle": "^2.3.2", "arch": "^2.2.0", @@ -2673,7 +2673,8 @@ "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "optional": true }, "node_modules/universalify": { "version": "2.0.1", diff --git a/test/package.json b/test/package.json index 7f9e24b..1c80b90 100644 --- a/test/package.json +++ b/test/package.json @@ -12,7 +12,7 @@ "license": "ISC", "dependencies": { "@smartbear/visualtest-cypress": "file:..", - "cypress": "^13.6.2", + "cypress": "^13.6.3", "mochawesome": "^7.1.3", "mochawesome-merge": "^4.3.0" }