From 5cc1279b4b1895c4cc103fa721f601880137071a Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 15 Sep 2025 14:23:25 +0200 Subject: [PATCH] Bug 40809: Fail Cypress tests on JS warnings Currently JS warnings during Cypress tests are ignored. This change intercepts console warnings in the browser and if any occurs the test failed This helps catch potential issues and ensures that warnings are not silently ignored during test runs. --- t/cypress/support/e2e.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/t/cypress/support/e2e.js b/t/cypress/support/e2e.js index bcffe74d50b..b395ad1e2e3 100644 --- a/t/cypress/support/e2e.js +++ b/t/cypress/support/e2e.js @@ -24,6 +24,15 @@ // -- This will overwrite an existing command -- // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) +// Error on JS warnings +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]}`); + } + }; +}); + function get_fallback_login_value(param) { var env_var = param == "username" ? "KOHA_USER" : "KOHA_PASS"; -- 2.34.1