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) |
}, |
Wladimir Palant
2017/11/28 12:59:39
Just remove console here, not overriding this glob
hub
2017/11/28 15:29:33
Done in follow up patch
|
navigator: { |
}, |
onShutdown: { |
add() {} |
}, |
URL |
}; |
@@ -414,16 +414,35 @@ |
Date: { |
now: () => currentTime |
} |
}; |
}; |
console.warn = console.log; |
+exports.silenceAssertionOutput = function(test, msg) |
+{ |
+ let msgMatch = new RegExp(`^Error: ${msg}[\r\n]`); |
Wladimir Palant
2017/11/28 12:59:40
1) Inserting unescaped strings into a regular expr
hub
2017/11/28 15:29:33
Done in followup patch.
|
+ let errorHandler = globals.console.error; |
+ globals.console.error = s => |
+ { |
+ if (!msgMatch.test(s)) |
+ errorHandler(s); |
+ }; |
+ try |
+ { |
+ return test(); |
+ } |
+ finally |
+ { |
+ globals.console.error = errorHandler; |
+ } |
+}; |
+ |
exports.setupRandomResult = function() |
{ |
let randomResult = 0.5; |
Object.defineProperty(this, "randomResult", { |
get: () => randomResult, |
set: value => randomResult = value |
}); |