create-react-app: React-scripts test is swallowing console logs, warnings, and errors
Can you reproduce the problem with latest npm?
Yes, I’m already on npm@4.0.5
.
Description
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
.
Expected behavior
I would expect any of these console
statements to print to stdout somewhere in the test output.
Actual behavior
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.
Environment
-
npm ls react-scripts
(if you haven’t ejected): 0.8.5 -
node -v
: v7.4.0 -
npm -v
: 4.0.5 -
Operating system: OSX 10.11.6
-
Browser and version: n/a
Reproducible Demo
See description
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 7
- Comments: 16 (8 by maintainers)
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?
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”