React-scripts test is swallowing console logs, warnings, and errors
See original GitHub issueCan 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
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:16 (8 by maintainers)
Top Results From Across the Web
React-scripts test is swallowing console logs, warnings, and errors
React -scripts test is swallowing console logs, warnings, and errors. ... React-scripts test is swallowing console logs, warnings, and errors.
Read more >Console.log statements output nothing at all in Jest
Run console.debug('Message here', yourValueHere) inside test function and it should show in the console output when running test script. You can ...
Read more >jest console log after tests are done - You.com | The AI Search ...
I was using the react-native default test case (see below) when Cannot log after ... Attempted to log "Warning: NOT valid form element"....
Read more >Changelog - Cypress Documentation
Compile errors are now surfaced in the command log during tests for Angular ... Add a warning for users on the old React...
Read more >How does MDN Intercept `console.log`? | DevLog 003
MDN's interactive examples override the browser's console.log, formats the arguments for ... I created a component in React that accomplishes the same thing....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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