-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Unit test failures on React 15.2.1 #7231
Comments
I think this is because you are running a prod version of React in your tests. The testutils aren't entirely compatible with that (and generally expect that you're running in dev mode). This case in particular is going to blame to #7189 because we actually removed some dead code that wasn't used in production builds. The way did that removal broke your use case though. cc @gaearon. The line at issue is |
Oops, I thought TestUtils are dev-only. Were we technically supporting running them in prod? |
They had worked up until now, but it seems reasonable to not have them supported in production. It should be pretty simple to adjust my build to not set |
Was using NODE_ENV=production to avoid warnings in my |
We’ll include a fix in the next version. Sorry I messed it up |
This will be fixed by #7246. |
This should prevent React from throwing an error in cases where the NODE_ENV is set to production Ref: facebook/react#7231
This is to avoid a regression in v15.2.1 where an error is being thrown in cases where the production build is used during testing Ref: facebook/react#7231
@zpao @gaearon -- Is there a solution in mind going forward for CI testing? We run our tests on CircleCI, and want them to run in the production environment so they're as representative as possible of how the code will actually behave in production. Switching that test environment to dev feels like it would defeat one of the central purposes of a CI server. |
There should be no difference (except perf and warnings) between dev and prod versions of React. This is super important for us at Facebook and we are committed to keeping it this way. So I don't think running unit tests with prod env would be valuable to you. |
(End to end tests are a different matter but you wouldn't need TestUtils for them anyway.) |
This is to avoid a regression in v15.2.1 where an error is being thrown in cases where the production build is used during testing Ref: facebook/react#7231
This is to avoid a regression in v15.2.1 where an error is being thrown in cases where the production build is used during testing Ref: facebook/react#7231
Bug
Unit tests using shallow rendering fail on 'TypeError: Cannot read property 'onSetDisplayName' of null'.
I can't seem to get TestUtils into jsfiddle, but here is the build output and code snippet.
What is the expected behavior?
Unit test should run normally.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
15.2.1 has this issue.
15.2.0 does not.
The text was updated successfully, but these errors were encountered: