| 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 |
| }); |