[IMP] web: reduce warning spam, only show rpc error warning in debug

Trigger a *lot* of spam while running tests

It's not great that this is now disabled:

* some cases are mistakes in the test e.g. RPC not properly setup,
  they should really be fixed
* others are literally testing error responses, the logging should be
  suppressed instead

Ideal scenario would probably be to upgrade this to `error` and have
an API of some sort to suppress it on a per-test basis (not unlike
`@mute_logger` on the Python side).
This commit is contained in:
Xavier Morel
2021-06-29 05:34:16 +00:00
parent 9528fd350f
commit 29de1ef72b
@@ -166,7 +166,15 @@ var MockServer = Class.extend({
var message = result && result.message;
var event = result && result.event;
var errorString = JSON.stringify(message || false);
console.warn('%c[rpc] response (error) ' + route, 'color: orange; font-weight: bold;', JSON.parse(errorString));
if (debug) {
console.warn(
'%c[rpc] response (error) %s%s, during test %s',
'color: orange; font-weight: bold;',
route,
message != null && ` -> ${errorString}`,
JSON.stringify(QUnit.config.current.testName)
);
}
return Promise.reject({message: errorString, event: event || $.Event()});
});