react-hot-loader: Version 4.8.5 introduces a new console error on every file unit tested with jest

Description

Whereas before, my unit test suite would pass without errors or warnings, simply by upgrading my version from 4.8.4 to 4.8.5, I get the following console error on every file:

image

Expected behavior

No error as with version 4.8.4, since I haven’t touched any files, other thank package.json.

Actual behavior

image

Environment

React Hot Loader version: 4.8.5

Run these commands in the project folder and fill in their results:

  1. node -v: 11.1.0
  2. npm -v: 6.9.0

Then, specify:

  1. Operating system: Osx
  2. Browser and version: Chrome, 74

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 6
  • Comments: 31

Commits related to this issue

Most upvoted comments

Try v4.8.8. Sorry @tommarien - saw you message too late 😄

For jest I think node_env is test while running, could we add it to the disabled state. Seems like a common approach what do you think ? On 23 May 2019, 08:15 +0200, Anton Korzunov notifications@github.com, wrote:

Agree, right now it’s NODE_ENV === “production”, partially BABEL_ENV === “production”(disables only babel plugin), and the absence of window (which may present during the tests). If that’s not enough - we should create a better way(s) to control it, and document it better than what we have today. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

I have a load of tests whereby I need to explicitly set process.env.NODE_ENV to something other than “test” - for example testing routes that are only added to development builds, etc.

It would be nice to have a workaround for this - for now, I will need to pin to 4.8.4…

So it always was just a console.error and I’ve fixed throw new Error in hot, which does a bit different thing.

Let me think about a proper way to fix this, but for now the best way to address this issue is to remove babel plugin in jest environment. It’s adding RHL registration code to the every file, but you don’t need it for tests.