method
test.default.TestContext.log
log(
message: string,
data?: unknown
): void;
This function is used to write a log message to the output. Unlike context.diagnostic, the resulting 'test:log' event is emitted immediately, in the order that the tests execute, rather than being buffered until the test reports its results. This function does not return a value.
test('top level test', (t) => {
t.log('fetched user', { userId: 42 });
t.log('retrying flaky endpoint', { attempt: 3 });
});@param message
Message to be reported.
@param data
Optional structured payload attached to the message. The test runner passes it through untouched. When tests run with process isolation, this value must be compatible with the HTML structured clone algorithm.