-
-
Notifications
You must be signed in to change notification settings - Fork 215
VirtualConsolePrinter.read()
David Ortner edited this page Jan 21, 2025
·
1 revision
Reads log entries from the console stream. This will clear the stream.
read(): IVirtualConsoleLogEntry[];
import { Window } from 'happy-dom';
const window = new Window();
window.console.log('Test', { test: true });
const entries = window.happyDOM.virtualConsolePrinter.read();
const log = entries.map(entry => entry.message.join(' ')).join('\n');
// Will output 'Test [object Object]' to the NodeJS console
global.console.log(log);
Help Packages