Open AviBueno opened 2 weeks ago
I would try with consecutive
with an empty array. However, this is not covered by tests.
Thanks @mcollina, it failes on time out.
I think there's room to support something like:
await pinoTest.zero(stream)
await expect(pinoTest).toHaveBeenCalledTimes(0)
It's a good PR to make!
A new never(stream)
API may be useful for this; in the meantime, you could check the length of the readable stream
const func = (b, logger) => {
if (b === true) {
logger.info("b is true");
}
}
test('should never log', () => {
const stream = pinoTest.sink()
const instance = pino(stream)
func(false, instance)
assert.strictEqual(stream.readableLength, 0, 'Stream should not have received any logs')
})
Sounds awesome @ruddenchaux! Thanks for the workaround. That works.
Side note: Finally! Great addition to pino!
Question: How could I check that pino was not called at all when calling
func(false, logger)
?