Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Why does jestjs-console.log output nothing?


Asked by Hendrix Reilly on Dec 06, 2021 FAQ



Check for your command line flags in package.json to see that you don't have --silent in there. Also be sure that your jest config does not have silent: true. In my case, I didn't realize that someone else had added that to our config.
In addition,
Jest suppresses the console log message by default. In order to show the console log message, set silent option to false at the command line in addition to --verbose option which can cause this as mentioned, be aware that the --watch may also cause this bug.
Likewise, Jest runs a test. Jest outputs the console.log statements (don't blink here) Jest scrolls back up an arbitrary number of lines, which sometimes covers all the console.log lines, sometimes some and sometimes all. Jest runs the next test (console.log lines from previous test disappear).
Thereof,
If Jest's own test suite using node 4 fails for you, then something is likely wrong with your setup. Sorry, something went wrong. Cloning the repository and giving it a try now. Sorry, something went wrong. Everything passed except for these 3 tests. Not sure what implications that might have.
Besides,
To make import work in Jest, package.json should have the key type configured as module, (see Node.js doc for more) and Jest must be called through Node.js with a flag: "scripts": { "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js" }, "type": "module", Once done you can start using import in Jest.