From 4d140d3fbd24507c82f9b8b6564242dab0dd60e3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 26 Sep 2025 12:38:00 +0200 Subject: [PATCH] Bug 40809: Display the whole error Not only the first line --- t/cypress/support/e2e.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/t/cypress/support/e2e.js b/t/cypress/support/e2e.js index e5062f748c3..a84b4872a2a 100644 --- a/t/cypress/support/e2e.js +++ b/t/cypress/support/e2e.js @@ -25,20 +25,26 @@ // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) // Error on JS warnings +function safeToString(arg) { + try { + return JSON.stringify(arg); + } catch (e) { + return `[object ${arg.constructor?.name || typeof arg}]`; + } +} + +function stringifyArgs(args) { + return args.map(safeToString).join(" "); +} Cypress.on("window:before:load", win => { win.console.warn = (...args) => { - if (args[0] && typeof args[0] === "string") { - throw new Error(`JS Warning detected: ${args[0]}`); - } + const message = stringifyArgs(args); + throw new Error(`JS Warning detected: ${message}`); }; win.console.log = (...args) => { - if (args[0] && typeof args[0] === "string") { - if (args[0].match(/DataTables warning: /)) { - throw new Error( - `DataTables warning detected in log: ${args[0]}` - ); - } - console.log(args[0]); + const message = stringifyArgs(args); + if (message.match(/DataTables warning: /)) { + throw new Error(`DataTables warning detected in log: ${message}`); } }; }); -- 2.34.1