From 3cda6237efaaf2f6b4c3775c9d1eed36047ec11d Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Thu, 9 May 2019 18:09:06 +0200 Subject: Do not show deprecation warnings during test runs Signed-off-by: Christoph Wurst --- core/src/globals.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'core/src') diff --git a/core/src/globals.js b/core/src/globals.js index 8476ccaf18e..312952fe90c 100644 --- a/core/src/globals.js +++ b/core/src/globals.js @@ -21,6 +21,12 @@ import appswebroots from "./OC/appswebroots"; +const warnIfNotTesting = function() { + if (window.TESTING === undefined) { + console.warn.apply(console, arguments) + } +} + /** * * @param {Function} func the library to deprecate @@ -29,7 +35,7 @@ import appswebroots from "./OC/appswebroots"; const deprecate = (func, funcName) => { const oldFunc = func const newFunc = function() { - console.warn(`The ${funcName} library is deprecated! It will be removed in nextcloud 19.`) + warnIfNotTesting(`The ${funcName} library is deprecated! It will be removed in nextcloud 19.`) return oldFunc.apply(this, arguments) } Object.assign(newFunc, oldFunc) @@ -43,9 +49,9 @@ const setDeprecatedProp = (global, val, msg) => { Object.defineProperty(window, global, { get: () => { if (msg) { - console.warn(`${global} is deprecated: ${msg}`) + warnIfNotTesting(`${global} is deprecated: ${msg}`) } else { - console.warn(`${global} is deprecated`) + warnIfNotTesting(`${global} is deprecated`) } return val } -- cgit v1.2.3