Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/_common.js

Issue 29616611: Issue 6090 - Allow use of console to be seen during tests (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Nov. 23, 2017, 7:19 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/filterStorage.js » ('j') | test/filterStorage.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/_common.js
===================================================================
--- a/test/_common.js
+++ b/test/_common.js
@@ -414,16 +414,35 @@
Date: {
now: () => currentTime
}
};
};
console.warn = console.log;
+exports.maybeExpectError = function(msg, test)
sergei 2017/11/24 10:15:28 What about calling it `silenceAssertionOutput`?
sergei 2017/11/24 13:49:13 JIC, I also thought that we could want to actually
hub 2017/11/24 15:48:59 Done.
hub 2017/11/24 15:48:59 I thought about expecting the output but then I'd
+{
+ let msgMatch = new RegExp(`^Error: ${msg}[\r\n]`);
+ let errorHandler = globals.console.error;
sergei 2017/11/24 10:15:28 I think it's OK taking into account that `console`
hub 2017/11/24 15:48:59 I'm missing a patch here where we actualle make co
+ globals.console.error = s =>
+ {
+ if (!msgMatch.test(s) && typeof errorHandler === "function")
sergei 2017/11/24 10:15:28 I think we should not test the type of errorHandle
hub 2017/11/24 15:48:59 Acknowledged.
+ errorHandler(s);
+ };
+ try
+ {
+ test();
sergei 2017/11/24 10:15:28 IMO we should return the result of `test()` for th
hub 2017/11/24 15:48:59 Acknowledged.
+ }
+ finally
+ {
+ globals.console.error = errorHandler;
+ }
+};
+
exports.setupRandomResult = function()
{
let randomResult = 0.5;
Object.defineProperty(this, "randomResult", {
get: () => randomResult,
set: value => randomResult = value
});
« no previous file with comments | « no previous file | test/filterStorage.js » ('j') | test/filterStorage.js » ('J')

Powered by Google App Engine
This is Rietveld