diff --git a/addons/web/static/lib/qunit/qunit-2.9.1.js b/addons/web/static/lib/qunit/qunit-2.9.1.js index 7efc1f1f759..f456cc15750 100644 --- a/addons/web/static/lib/qunit/qunit-2.9.1.js +++ b/addons/web/static/lib/qunit/qunit-2.9.1.js @@ -2981,6 +2981,7 @@ } Test.prototype = { + get moduleName() { return this.module.name; }, before: function before() { var _this = this; @@ -3147,7 +3148,7 @@ this.pushFailure("Expected at least one assertion, but none were run - call " + "expect(0) to accept zero assertions.", this.stack); } - emit("OdooAfterTestHook", { moduleName: this.module.name, testName: this.testName }); // Odoo customization + emit("OdooAfterTestHook", this); // Odoo customization var i, module = this.module, diff --git a/addons/web/static/tests/helpers/cleanup.js b/addons/web/static/tests/helpers/cleanup.js index d68bc467ee3..9aeec42977c 100644 --- a/addons/web/static/tests/helpers/cleanup.js +++ b/addons/web/static/tests/helpers/cleanup.js @@ -72,17 +72,15 @@ QUnit.on("OdooAfterTestHook", function (info) { if (QUnit.config.debug) { return; } + const failed = info.testReport.getStatus() === 'failed'; const toRemove = []; // check for leftover elements in the body for (const bodyChild of document.body.children) { const tolerated = validElements.find( (e) => e.tagName === bodyChild.tagName && bodyChild.getAttribute(e.attr) === e.value ); - if (!tolerated) { - console.error( -`Test ${info.moduleName} > ${info.testName}: body still contains undesirable elements: - ${bodyChild.outerHTML}`); - QUnit.pushFailure(`Body still contains undesirable elements`); + if (!failed && !tolerated) { + QUnit.pushFailure(`Body still contains undesirable elements:\n${bodyChild.outerHTML}`); } if (!tolerated || !tolerated.keep) { toRemove.push(bodyChild);