Jest: console.debug is missing

Created on 21 Jan 2016  路  4Comments  路  Source: facebook/jest

I have a feeling it somehow relates to: https://github.com/facebook/jest/blob/master/src/Console.js

But trying to use console.debug() in a test tells me it isn't there, but .warn(), .log(), and .error() work as expected.

Most helpful comment

Jan 2016 -> "I don't think I'll add this to jest. There is no real reason."
Mar 2018 -> "console.debug has been implemented in Jest".

Lulz.

All 4 comments

There is no real reason to include this because it just maps to console.log. I actually didn't even know it existed. If you need this, I'd recommend doing console.debug = console.log in your setup env file or in the beforeEach call of your associated test. I don't think I'll add this to jest.

For others looking for a similar thing. I'm using 'loglevel' for browser logging and got my logs back while running Jest by doing this (as suggested above):

In the "jest" config (in package.json):

"setupFiles": [
    "./jest-setup.js"
],

At the same directory level as 'package.json', created a file called 'jest-setup.js' which contained:

var log = require('loglevel');

log.info = console.log;
log.debug = console.log;
log.trace = console.log;
console.debug = console.log;
console.trace = console.log;
console.info = console.log;

It's not perfect, but I see everything I want.

console.debug has been implemented in Jest since #5350 (available in jest 22.1.4)

Jan 2016 -> "I don't think I'll add this to jest. There is no real reason."
Mar 2018 -> "console.debug has been implemented in Jest".

Lulz.

Was this page helpful?
0 / 5 - 0 ratings