From ce79cb579784e8417596fed03f3d2a5bbbad487d Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Sat, 4 Sep 2021 21:16:35 +0800 Subject: refactor(testing): redirect console output via reporter (#11911) This feeds console output to the reporter and handles silencing there instead of in the JavaScript code. --- runtime/js/40_testing.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'runtime/js/40_testing.js') diff --git a/runtime/js/40_testing.js b/runtime/js/40_testing.js index 617df22d4..4e7c231b2 100644 --- a/runtime/js/40_testing.js +++ b/runtime/js/40_testing.js @@ -228,15 +228,19 @@ finishing test case.`; } async function runTests({ - disableLog = false, filter = null, shuffle = null, } = {}) { const origin = getTestOrigin(); const originalConsole = globalThis.console; - if (disableLog) { - globalThis.console = new Console(() => {}); - } + + globalThis.console = new Console((line) => { + dispatchTestEvent({ + output: { + console: line, + }, + }); + }); const only = ArrayPrototypeFilter(tests, (test) => test.only); const filtered = ArrayPrototypeFilter( @@ -286,9 +290,7 @@ finishing test case.`; dispatchTestEvent({ result: [description, result, elapsed] }); } - if (disableLog) { - globalThis.console = originalConsole; - } + globalThis.console = originalConsole; } window.__bootstrap.internals = { -- cgit v1.2.3