This is a really old question, but I stumbled across it trying to solve something similar. I ended up using Deno's built in mocking to set up a spy in a test and checking to make sure console.log
was called with the expected value.
import {
assertSpyCall,
spy,
} from "https://deno.land/std@0.165.0/testing/mock.ts";
function veryImportantLogger(val: string) {
console.log(val)
}
Deno.test("Checks to make sure the right value is logged", () => {
const logSpy = spy(console, "log");
const logValue = "well hello there";
veryImportantLogger(logValue);
assertSpyCall(logSpy, 0, {
args: [logValue]
});
});