Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import React when importing react-test-renderer in component tests #5

Open
erickakoyama opened this issue Mar 25, 2019 · 0 comments
Open

Comments

@erickakoyama
Copy link

erickakoyama commented Mar 25, 2019

It seems like React also needs to be imported in the test file for the TestRenderer to work. The setup I am using is:

"jest": "^23.4.1"
"react": "^16.8.2"
"react-test-renderer": "^16.8.3"

When running the jest unit tests I get the following error:

ReferenceError: React is not defined

Writing the import as the following seems to solve it for me:

import * as TestRenderer from 'react-test-renderer';
import React from 'react';

Also, for many test files that already contained a metal Component import, there is an import for React, but if it didn't have it explicitly before it seems to also need it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant