Skip to content

Commit

Permalink
SBVT-1379: include freezepageResults on the response & update qa tests (
Browse files Browse the repository at this point in the history
#83)

* SBVT-1379:
return the freezePageResults on the object\
add all the tests

* SBVT-1379:
update gitIgnore
cypress config file now reports at the end of a run for the npm test

* SBVT-1379:
make the mocawesome logs quiet

* SBVT-1379: move getDescribeTitle.js to a function

* SBVT-1379: move flattendom to a function and remove unused

* SBVT-1379: syntax fix

* SBVT-1379: describe title changes

* SBVT-1379: refactor bin -> utils folder

---------

Co-authored-by: trevor.nelms <[email protected]>
  • Loading branch information
tnelms1 and trevor.nelms authored May 2, 2023
1 parent 7c4ca9e commit a96b3fc
Show file tree
Hide file tree
Showing 16 changed files with 4,542 additions and 1,568 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
.env
/node_modules
test/node_modules
test/cypress/screenshots/*
test/cypress/screenshots
test/cypress/dom
test/cypress/videos/*
test/cypress/videos
test/cypress/e2e/*
!test/cypress/e2e/test-spec/
test/mochawesome-report
sessionId.txt
10 changes: 6 additions & 4 deletions commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const headers = {

let apiRes;
let picProps, blobData, userAgentData, picElements, imageName, vtConfFile, dom, toolkitScripts, deviceInfoResponse,
fullpageData, saveDOM, imageType, runFreezePage, platformVersion;
fullpageData, saveDOM, imageType, runFreezePage, platformVersion, freezePageResult;

Cypress.Commands.add('sbvtCapture', {prevSubject: 'optional'}, (element, name, options) => {
imageType = "fullPage"; //default to fullpage each time a user runs sbvtCapture
Expand Down Expand Up @@ -95,7 +95,7 @@ let takeScreenshot = (element, name, modifiedOptions, win) => {
modifiedOptions.freezePage !== false ? runFreezePage = true : runFreezePage = false
if (!modifiedOptions.lazyload && runFreezePage) {
cy.task('logger', {type: 'debug', message: `running freezePage at the beginning.`});
win.eval(toolkitScripts.freezePage)
freezePageResult = win.eval(toolkitScripts.freezePage)
}
}

Expand Down Expand Up @@ -186,7 +186,7 @@ let takeScreenshot = (element, name, modifiedOptions, win) => {
cy.wait(1000);
if (runFreezePage) {
cy.task('logger', {type: 'debug', message: `running freezePage in the lazyload function.`});
win.eval(toolkitScripts.freezePage)
freezePageResult = win.eval(toolkitScripts.freezePage)
}
}

Expand Down Expand Up @@ -248,7 +248,8 @@ let takeScreenshot = (element, name, modifiedOptions, win) => {
}
cy.task('logger', {type: 'info', message: `starting cypress's default fullpage screenshot`})
if (runFreezePage) {
win.eval(toolkitScripts.freezePage)
// 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.`});
}
cy.screenshot(
Expand Down Expand Up @@ -298,6 +299,7 @@ let sendImageApiJSON = () => {
height: imagePostData.imageHeight
},
devicePixelRatio: imagePostData.devicePixelRatio,
freezePageResult
}
cy.request({
method: "POST",
Expand Down
55 changes: 46 additions & 9 deletions test/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,51 @@
const { defineConfig } = require("cypress");
const {defineConfig} = require("cypress");
const chalk = require("chalk");
const deletePastReports = require("./utils/deletePastReports")
const generateReports = require("./utils/generateReports")


module.exports = defineConfig({
// viewportWidth: 1920,
// viewportHeight: 1080,
video: false,
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
// viewportWidth: 1920,
// viewportHeight: 1080,
reporterOptions: {
overwrite: false,
html: false,
json: true,
timestamp: "mm/dd/yyyy_HH|MM|ss",
quiet: true
},
bail: true,
video: false,
e2e: {
setupNodeEvents(on) {

on('before:run', (results) => {
if (results.config.reporter === "mochawesome") {
deletePastReports()
}
})
on('after:run', (results) => {
//todo fix the sbvt after test report being overwritten

if (results.config.reporter === "mochawesome") {
generateReports()
printResults(results)
}
})
},
},
},
});

require('@smartbear/visualtest-cypress')(module)
require('@smartbear/visualtest-cypress')(module)

const printResults = (results) => {
if (results.totalFailed) {
process.stdout.write(`\t`);
process.stdout.write(chalk.bgRedBright(`there was ${results.totalFailed} ${results.totalFailed === 1 ? 'failure' : 'failures'}`));
}
if (results.totalPassed) {
process.stdout.write(`\t`);
process.stdout.write(chalk.green(`there was ${results.totalPassed} passed ${results.totalPassed === 1 ? 'test' : 'tests'}`));
}
}

89 changes: 0 additions & 89 deletions test/cypress/e2e/test-spec/cssTest.cy.js

This file was deleted.

Loading

0 comments on commit a96b3fc

Please sign in to comment.