Yes, I'm already on [email protected].
Create a new app:
create-react-app test-app
cd test-app
Add the following tests to src/App.test.js:
it('should log when test passes', () => {
console.log('test');
console.warn('test');
console.error('test');
expect(0).toEqual(0);
});
it('should log when test fails', () => {
console.log('test');
console.warn('test');
console.error('test');
expect(0).toEqual(1);
});
Run the tests with either yarn or npm.
I would expect any of these console statements to print to stdout somewhere in the test output.
The test output shows two passing tests and one failing test, as expected, along with the usual general test info and commands. But the logged output is nowhere to be found.
npm ls react-scripts (if you haven鈥檛 ejected): 0.8.5node -v: v7.4.0npm -v: 4.0.5
Operating system: OSX 10.11.6
See description
I know this might end up being an issue with jest, but I figured I'd start here because I'm unsure how react-scripts is wrapping the test runner.
This might be an issue with Jest on Node 7:
https://github.com/facebook/jest/pull/2457
https://github.com/nodejs/node/issues/10492
Can you clone CRA and verify whether upgrading Jest packages to 18.1.0 fixes the issue?
In particular you'd need to clone the repo and run npm install.
Then you could put some logs in packages/react-scripts/template/src/App.test.js and verify npm test at the top level swallows them.
Then you could bump Jest package versions in packages/react-scripts/package.json and run npm install there.
Then run npm test at the top level again and verify it works this time.
Alright, I cloned CRA and added tests with logging. Passing and failing tests show all expected console output. I attempted to generate an app with my clone of CRA with npm run create-react-app test-app and went through the same steps as before. This had the expected output as well.
So this must mean it's an environment thing for me, right? What is different between testing the templates within my clone of CRA vs. testing a generated app with my clone of CRA (both of which have the proper output)? And how was my globally installed npm package of CRA any different to cause the initial issue?
We updated Jest in master to 18.0 in https://github.com/facebookincubator/create-react-app/pull/1311 but it鈥檚 not in any CRA release yet. So maybe that fixed it for you? Can you try reverting that commit locally?
Yup, that worked. I reverted to #1274, the commit previous to #1311, and there was no logged output. I then checked out #1311 and the output is there.
Maybe we can cut 0.9 with just the Jest update and a few fixes, and postpone bigger plans for 0.10. @fson What do you think?
i know 0.8.5 was only released 5 days ago, so I'm assuming the 0.9 release might be a while. that's totally fine. is there anything I might be able to do in the meantime as a workaround?
@gaearon I think 0.8.6 will be better for Jest updating and bug fixes
We can't cut 0.8.6 for this because Jest 17 => 18 contained breaking changes.
Appears fixed with [email protected] which contains Jest 18.

thanks for the fix!
Thank you for reporting!
Hi @gaearon
How can I make console.log map where they are called if I am using Jest (20). I am not using react-scripts. Or if you have any reference, can you post it here?
Thank you very much.
This issue has been closed for a while, but it popped again for me today. For those who may also be looking for a solution over a year later, some searching suggested that adding the --verbose=false flag may resolve it. Indeed, it did.
Specifically, in package.json I updated the line for the test script to be "test": "react-scripts test --env=jsdom --verbose=false"
https://github.com/facebook/jest/issues/2441#issuecomment-424310466
I fell over this yesterday as well but it turned out that without 'watch' it worked. run the following on windows for test now "set CI=true && react-scripts test"
Most helpful comment
Maybe we can cut 0.9 with just the Jest update and a few fixes, and postpone bigger plans for 0.10. @fson What do you think?