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 1e8e542c87c..303d4fb40de 100644 --- a/addons/web/static/lib/qunit/qunit-2.9.1.js +++ b/addons/web/static/lib/qunit/qunit-2.9.1.js @@ -3142,7 +3142,7 @@ this.pushFailure("Expected at least one assertion, but none were run - call " + "expect(0) to accept zero assertions.", this.stack); } - emit("OdooAfterTestHook"); // Odoo customization + emit("OdooAfterTestHook", { moduleName: this.module.name, testName: this.testName }); // Odoo customization var i, module = this.module, diff --git a/addons/web/static/tests/helpers/qunit_config.js b/addons/web/static/tests/helpers/qunit_config.js index 48c17d90a98..a8c42fee8b3 100644 --- a/addons/web/static/tests/helpers/qunit_config.js +++ b/addons/web/static/tests/helpers/qunit_config.js @@ -159,8 +159,10 @@ QUnit.moduleDone(function(result) { * After each test, we check that there is no leftover in the DOM. * * Note: this event is not QUnit standard, we added it for this specific use case. + * As a payload, an object with keys 'moduleName' and 'testName' is provided. It + * is used to indicate the test that left elements in the DOM, when it happens. */ -QUnit.on('OdooAfterTestHook', function () { +QUnit.on('OdooAfterTestHook', function (info) { const toRemove = []; // check for leftover elements in the body for (const bodyChild of document.body.children) { @@ -168,9 +170,9 @@ QUnit.on('OdooAfterTestHook', function () { e.tagName === bodyChild.tagName && bodyChild[e.attr] === e.value ); if (!tolerated) { + console.error(`Test ${info.moduleName} > ${info.testName}`); console.error('Body still contains undesirable elements:' + - '\nInvalid element:\n' + bodyChild.outerHTML + - '\nBody HTML: \n' + $('body').html()); + '\nInvalid element:\n' + bodyChild.outerHTML); QUnit.pushFailure(`Body still contains undesirable elements`); } if (!tolerated || !tolerated.keep) {