From b1ce5f2fdf3f5586df19cd2a9c36591c84131f8a Mon Sep 17 00:00:00 2001 From: Joshua Date: Thu, 1 Feb 2024 14:45:03 +0100 Subject: [PATCH] cleanup --- cypress/e2e/1.cy.js | 2 +- src/snapshot.js | 22 +++++++++++++--------- src/utils/compareValues.js | 3 --- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/cypress/e2e/1.cy.js b/cypress/e2e/1.cy.js index 11a4807..4e3cb70 100644 --- a/cypress/e2e/1.cy.js +++ b/cypress/e2e/1.cy.js @@ -50,7 +50,7 @@ describe("datashard/snapshot", () => { "response": { "array": [0, 1, 2, "4"], "object": { - // "with": "more details" + "with": "more details" } }, "thisisnew": "wtf" diff --git a/src/snapshot.js b/src/snapshot.js index 135d47b..1dc6c74 100644 --- a/src/snapshot.js +++ b/src/snapshot.js @@ -21,6 +21,7 @@ const parseTextToJSON = (text) => text.replace(/\| [✅➖➕⭕]/g, "").trim(). const store_snapshot = (props = { value, name, raiser }) => { if (Cypress.env().updateSnapshots || Cypress.config('snapshot').updateSnapshots) { + cy.SNAPSHOT_prettyprint({ title: "INFO", type: "info", message: "Saving Snapshot" }) cy.writeFile(`${props.name}.json`, JSON.stringify(props.value, null, 2)) } else { // TODO: Figure out how to replace the fixture folder name if people move it @@ -35,11 +36,16 @@ const set_snapshot = ({ snapshotName, serialized, value }) => { devToolsLog.$el = value; } + let options = { + name: "snapshot", + message: snapshotName, + consoleProps: () => { return devToolsLog }, + }; + if (value) options.$el = value; const raiser = ({ value, expected }) => { const result = compareValues({ expected, value }); - // console.log("Final Result", result.result) if ((!Cypress.env().updateSnapshots || !Cypress.config('snapshot').updateSnapshots) && !result.success) { devToolsLog = () => { return { expected, value } @@ -51,18 +57,16 @@ const set_snapshot = ({ snapshotName, serialized, value }) => { Cypress.log({ message: error(true) }) throw new Error(error()); + } else { + cy.SNAPSHOT_prettyprint({ + title: "SUCCESS", + message: snapshotName, + type: "success" + }) } }; - let options = { - name: "snapshot", - message: snapshotName, - consoleProps: () => { return devToolsLog }, - }; - if (value) options.$el = value; - - Cypress.log(options); store_snapshot({ value, diff --git a/src/utils/compareValues.js b/src/utils/compareValues.js index ce803cb..1c7c885 100644 --- a/src/utils/compareValues.js +++ b/src/utils/compareValues.js @@ -30,9 +30,6 @@ const compare = (expected, value) => { dataY = expected; } - console.log('datax', dataX) - console.log('dataY', dataY) - dataX.forEach(function (item, index) { const resultset = compare(item, dataY[index]); compareResult += resultset.result;