Skip to content

Mocking React components causes warnings with React 16 #5258

@pugnascotia

Description

@pugnascotia

I am reporting a bug, as reproduced in pugnascotia/test-jest-mock.

With React 16, when I mocked a component like so:

jest.mock('./Widget', () => 'Widget');

I routinely get warnings such as:

  console.error node_modules/fbjs/lib/warning.js:33
    Warning: <Widget /> is using uppercase HTML. Always use lowercase HTML tags in React.

  console.error node_modules/fbjs/lib/warning.js:33
    Warning: The tag <Widget> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.

The latter is less common, but the former happens a lot in my main application. I discovered it while migrating to React 16. The tests do pass and the snapshots seem OK, but the swathe of warnings is rather alarming.

In pugnascotia/test-jest-mock, this behaviour is seem both on the master branch, which uses Jest 20, and the jest22 branch, which uses Jest 22.

Needless to say, I didn't expect to see these warnings, because I never saw them using Jest and React 15.

My versions are:

$ node --version
v6.11.1
$ uname -a
Darwin __REDACTED__ 16.7.0 Darwin Kernel Version 16.7.0: Mon Nov 13 21:56:25 PST 2017; root:xnu-3789.72.11~1/RELEASE_X86_64 x86_64
$ yarn --version
1.3.2

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