bump cypress and redo logging

This commit is contained in:
Joshua 2024-02-01 11:58:42 +01:00
parent cb39e029c3
commit 960e699075
3 changed files with 73 additions and 694 deletions

730
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -37,7 +37,7 @@
"cypress:run": "cypress run"
},
"devDependencies": {
"cypress": "10.6.0",
"cypress": "12.13.0",
"debug": "3.2.7",
"dependency-check": "2.10.1"
},

View file

@ -17,7 +17,7 @@ const pickSerializer = (asJson, value) => {
* @returns {string}
*/
const parseTextToJSON = (text) => text.replace(/\| [✅➖➕⭕]/g, "").trim().replace(/(.*?),\s*(\}|])/g, "$1$2").replace(/},(?!")$/g, "}");
const parseTextToJSON = (text) => text.replace(/\| [✅➖➕⭕]/g, "").trim().replace(/(.*?),\s*(\}|])/g, "$1$2").replace(/},(?!")$/g, "}").replaceAll(/[╺┿╳]/g, "")
const store_snapshot = (props = { value, name, raiser }) => {
if (Cypress.env().updateSnapshots || Cypress.config('snapshot').updateSnapshots) {
@ -35,36 +35,33 @@ const set_snapshot = ({ snapshotName, serialized, value }) => {
devToolsLog.$el = value;
}
const options = {
name: "snapshot",
message: snapshotName,
consoleProps: () => 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 = {
...devToolsLog,
message: result,
expected,
value,
devToolsLog = () => {
return { expected, value }
};
throw new Error(
`Snapshot Difference found.\nPlease Update the Snapshot\n
const error = (inError) => `
Snapshot Difference found.\nPlease Update the Snapshot ${inError ? `\n${JSON.stringify(JSON.parse(parseTextToJSON(result.result)), null, 3).replaceAll(' ', " ")}` : ""}`
${JSON.stringify(
JSON.parse(parseTextToJSON(result.result).replaceAll(/[╺┿╳]/g, "")), null, 2)
.replaceAll(" ", " ")
}
Cypress.log({ message: error(true) })
`);
throw new Error(error());
}
};
let options = {
name: "snapshot",
message: snapshotName,
consoleProps: () => { return devToolsLog },
};
if (value) options.$el = value;
Cypress.log(options);
store_snapshot({