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" "cypress:run": "cypress run"
}, },
"devDependencies": { "devDependencies": {
"cypress": "10.6.0", "cypress": "12.13.0",
"debug": "3.2.7", "debug": "3.2.7",
"dependency-check": "2.10.1" "dependency-check": "2.10.1"
}, },

View file

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