Writing a Node CLI in my module I have a console.log with chalk, example:
console.log(
  chalk.green(`${delta}:`),
  chalk.white(`\nAPI: ${apiPath}`),
)
when I run a Jest code coverage --coverage I'm reminded that I didn't have a test so I wrote:
test(`Test console log`, async () => {
  await mod(params)
  await expect(console.log).toBe(`${delta}:\nAPI: ${apiPath}`)
})
but I get an error of:
Expected: "string"
Received: [Function log]
Second attempt from research I tried:
test(`Test console log`, async () => {
  await mod(params)
  await expect(console.log).toHaveBeenCalledWith(`${delta}:\nAPI: ${apiPath}`)
})
but I get an error of:
Received has type:  function
Received has value: [Function log]
Research:
- How do I test a jest console.log
- Console.log statements output nothing at all in Jest
- How to test console.log output using Jest or other Javascript Testing Framework?
With Jest how can I test a console.log that uses chalk?
 
    