Index: test/_common.js |
=================================================================== |
--- a/test/_common.js |
+++ b/test/_common.js |
@@ -87,18 +87,18 @@ |
throw new Error( |
"Attempt to import unknown JavaScript module " + resource |
); |
}, |
reportError(e) {} |
}, |
console: { |
- log() {}, |
- error() {} |
+ log: console.log.bind(console), |
+ error: console.error.bind(console) |
}, |
navigator: { |
}, |
onShutdown: { |
add() {} |
}, |
URL |
}; |
@@ -414,16 +414,37 @@ |
Date: { |
now: () => currentTime |
} |
}; |
}; |
console.warn = console.log; |
+exports.silenceAssertionOutput = function(test, msg) |
+{ |
+ let msgMatch = new RegExp(`^Error: ${msg}[\r\n]`); |
+ let errorHandler = globals.console.error; |
+ globals.console.error = s => |
+ { |
+ if (!msgMatch.test(s)) |
+ errorHandler(s); |
+ }; |
+ let result; |
+ try |
+ { |
+ result = test(); |
sergei
2017/11/24 16:46:27
There is no necessity in an additional variable, c
hub
2017/11/24 18:17:56
For some reason I believed that return would by-pa
|
+ } |
+ finally |
+ { |
+ globals.console.error = errorHandler; |
+ } |
+ return result; |
+}; |
+ |
exports.setupRandomResult = function() |
{ |
let randomResult = 0.5; |
Object.defineProperty(this, "randomResult", { |
get: () => randomResult, |
set: value => randomResult = value |
}); |