mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 02:22:40 +00:00
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:
parent
44ca3ce6ae
commit
ce79cb5797
3 changed files with 65 additions and 33 deletions
|
@ -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 = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue