-
-
Notifications
You must be signed in to change notification settings - Fork 213
VirtualConsolePrinter.readAsString()
David Ortner edited this page Jan 21, 2025
·
6 revisions
Adds an event listener.
readAsString(logLevel?: VirtualConsoleLogLevelEnum): string;
Parameter | Type | Default | Description |
---|---|---|---|
logLevel? | VirtualConsoleLogLevelEnum | VirtualConsoleLogLevelEnum.log | This log level or greater (e.g. "log" as level will output "log", "info", "warn" and "error") |
string
import { Window, VirtualConsoleLogLevelEnum } from "happy-dom";
const window = new Window();
window.console.log("Test", { test: true });
const log = window.happyDOM.virtualConsolePrinter.readAsString(
VirtualConsoleLogLevelEnum.log
);
// Will output 'Test {"test": true}' to the NodeJS console
global.console.log(log);
Help Packages