From b39c5072f7bb490f7d23fabc4f8930d97bbe94a8 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 11 Jun 2021 08:25:19 +0000 Subject: [PATCH] [FIX] web: avoid warning during qweb tests One of the qweb tests checks that in a t-set @t-value takes priority over body contents. However this construct also triggers a warning when invoked. Mock out `window.console` during qweb tests, this suppresses that warning. --- addons/web/static/tests/helpers/utils.js | 5 +++++ addons/web/static/tests/legacy/qweb_tests.js | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/web/static/tests/helpers/utils.js b/addons/web/static/tests/helpers/utils.js index f01c79b991b..cdf3bf7b88c 100644 --- a/addons/web/static/tests/helpers/utils.js +++ b/addons/web/static/tests/helpers/utils.js @@ -208,3 +208,8 @@ export async function legacyExtraNextTick() { export function mockDownload(cb) { patchWithCleanup(download, { _download: cb }); } + +export const hushConsole = Object.create(null); +for(const propName of Object.keys(window.console)) { + hushConsole[propName] = () => {} +} diff --git a/addons/web/static/tests/legacy/qweb_tests.js b/addons/web/static/tests/legacy/qweb_tests.js index fda72e2392b..dd2b0c527ec 100644 --- a/addons/web/static/tests/legacy/qweb_tests.js +++ b/addons/web/static/tests/legacy/qweb_tests.js @@ -2,6 +2,7 @@ odoo.define('web.qweb_tests', function (require) { "use strict"; var qwebPath = '/web/static/lib/qweb/'; +const {hushConsole} = require('@web/../tests/helpers/utils'); function trim(s) { return s.replace(/(^\s+|\s+$)/g, ''); @@ -63,7 +64,13 @@ function loadTest(assert, template, context) { return prom; } -QUnit.module('QWeb', {}, function () { +QUnit.module('QWeb', { + before() { + this.oldConsole = window.console; + window.console = hushConsole; + }, + after() {window.console = this.oldConsole;} +}, function () { QUnit.test('Output', function (assert) { loadTest(assert, 'qweb-test-output.xml'); });