summaryrefslogtreecommitdiff
path: root/runtime/js/40_testing.js
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2021-09-04 21:16:35 +0800
committerGitHub <noreply@github.com>2021-09-04 15:16:35 +0200
commitce79cb579784e8417596fed03f3d2a5bbbad487d (patch)
tree846d81dbbbf9408268d1c54aa865074717653537 /runtime/js/40_testing.js
parent44ca3ce6aeb99cb968776f5f13420e76acbc8117 (diff)
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.
Diffstat (limited to 'runtime/js/40_testing.js')
-rw-r--r--runtime/js/40_testing.js16
1 files changed, 9 insertions, 7 deletions
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 = {