Skip to content

React-scripts test is swallowing console logs, warnings, and errors #1368

Closed
@zachfedor

Description

@zachfedor

Can you reproduce the problem with latest npm?

Yes, I'm already on [email protected].

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

  1. npm ls react-scripts (if you haven’t ejected): 0.8.5

  2. node -v: v7.4.0

  3. npm -v: 4.0.5

  4. Operating system: OSX 10.11.6

  5. Browser and version: n/a

Reproducible Demo

See description

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions