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 303d4fb40de..9724e74e0b9 100644 --- a/addons/web/static/lib/qunit/qunit-2.9.1.js +++ b/addons/web/static/lib/qunit/qunit-2.9.1.js @@ -8,6 +8,7 @@ * * Date: 2019-01-07T16:37Z */ + (function (global$1) { 'use strict'; @@ -21,6 +22,7 @@ var document$1 = window$1 && window$1.document; var navigator = window$1 && window$1.navigator; + var lastError = null; var localSessionStorage = function () { var x = "qunit-test-string"; @@ -3031,6 +3033,7 @@ try { runTest(this); } catch (e) { + lastError = e; this.pushFailure("Died on test #" + (this.assertions.length + 1) + " " + this.stack + ": " + (e.message || e), extractStacktrace(e, 0)); // Else next test will carry the responsibility @@ -5331,7 +5334,18 @@ assertLi.className = details.result ? "pass" : "fail"; assertLi.innerHTML = message; assertList.appendChild(assertLi); - }); + + // Odoo Customisation!!! + // Crappy hack to display traceback with sourcemaps if debug=assets + if (lastError && QUnit.annotateTraceback && odoo && odoo.debug && odoo.debug.includes("assets")) { + const pre = assertLi.querySelector("pre"); + + QUnit.annotateTraceback(lastError).then(traceback => { + pre.innerText = traceback; + }); + lastError = null; + } + }); QUnit.testDone(function (details) { var testTitle, diff --git a/addons/web/static/src/js/core/error_utils.js b/addons/web/static/src/js/core/error_utils.js index 9bdc0a1009f..2ccfb5cd6db 100644 --- a/addons/web/static/src/js/core/error_utils.js +++ b/addons/web/static/src/js/core/error_utils.js @@ -1,7 +1,7 @@ /** @odoo-module **/ import { loadJS } from "web.ajax"; - +import BrowserDetection from "web.BrowserDetection"; /** * Format the traceback of an error. Basically, we just add the error message * in the traceback if necessary (Chrome already does it by default, but not diff --git a/addons/web/static/tests/helpers/qunit_config.js b/addons/web/static/tests/helpers/qunit_config.js index 575c8022d2b..580698c5490 100644 --- a/addons/web/static/tests/helpers/qunit_config.js +++ b/addons/web/static/tests/helpers/qunit_config.js @@ -237,6 +237,11 @@ QUnit.config.urlConfig.push({ }); QUnit.begin(function() { + if (odoo.__DEBUG__.services["@web/js/core/error_utils"]) { + const errorUtils = odoo.__DEBUG__.services["@web/js/core/error_utils"]; + const { annotateTraceback } = errorUtils + QUnit.annotateTraceback = annotateTraceback + } if (QUnit.config.failfast) { QUnit.testDone(function(details) { if (details.failed > 0) {