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.
This commit is contained in:
Casper Beyer 2021-09-04 21:16:35 +08:00 committed by GitHub
parent 44ca3ce6ae
commit ce79cb5797
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 33 deletions

View file

@ -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 = {