Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

React unit test warnings #144

Closed
shilman opened this issue May 29, 2016 · 8 comments
Closed

React unit test warnings #144

shilman opened this issue May 29, 2016 · 8 comments
Assignees

Comments

@shilman
Copy link

shilman commented May 29, 2016

When I run the react branch unit tests, I see the following error repeated three times (on MacOS El Capitan):

Unable to resolve some modules:

  "react/addons" in /Users/shilman/projects/meteor/todos/node_modules/enzyme/build/react-compat.js (os.osx.x86_64)
  "react/lib/ReactContext" in /Users/shilman/projects/meteor/todos/node_modules/enzyme/build/react-compat.js (os.osx.x86_64)
  "react/lib/ExecutionEnvironment" in /Users/shilman/projects/meteor/todos/node_modules/enzyme/build/react-compat.js (os.osx.x86_64)

If you notice problems related to these missing modules, consider running:

  meteor npm install --save react             

I believe they are caused by my pull request #141 but I'm not sure how to go about debugging this, and have already spent a few hours playing around with NPM and package versions.

Anybody have suggestions?

@shilman shilman changed the title React unit test errors React unit test warnings May 29, 2016
@shilman
Copy link
Author

shilman commented May 29, 2016

Possibly related: enzymejs/enzyme#47

You should be able to get around that error by just adding react/lib/ExecutionEnvironment to the list of externals.

This is a webpack configuration though -- don't know if it relates at all to NPM and/or Meteor...

@tmeasday tmeasday self-assigned this Jun 2, 2016
@tmeasday
Copy link
Contributor

tmeasday commented Jun 2, 2016

I'd like to dig deeper into this one. As you've pointed out, it is just a warning so I'm not super concerned about it; however it would be good to get a better handle on these kind of warnings as there is often real, important information buried amongst the warnings.

@martinhbramwell
Copy link

martinhbramwell commented Jun 5, 2016

I am also seeing this error while trying to use practicalmeteor:mocha with mantrajs/mantra-sample-blog-app.git. To replicate the problem, I do :

In Terminal 1 . . .

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

mkdir -p ~/projects
cd ~/projects
git clone https://github.com/mantrajs/mantra-sample-blog-app.git
cd mantra-sample-blog-app/
meteor npm install
meteor npm install --save meteor-node-stubs
meteor add practicalmeteor:mocha
meteor

Results in :

=> App running at: http://localhost:3000/

In Terminal 2 . . .

cd ~/projects/mantra-sample-blog-app
meteor test --driver-package practicalmeteor:mocha --port 3003

Results in :

=> App running at: http://localhost:3003/     
I20160605-06:58:57.784(-4)? MochaRunner.runServerTests: Starting server side tests with run id XYSDGsLJoWK37My5F
W20160605-06:58:57.785(-4)? (STDERR) MochaRunner.runServerTests: failures: 0

¡¡ However, since all tests are in directories named tests none are executed. !!

In Terminal 3 . . .

cd ~/projects/mantra-sample-blog-app
npm run testonly

Results in :

  53 passing (338ms)
  1 pending

To make it fail

In Terminal 3 . . .

mv ./client/modules/comments/components/tests ./client/modules/comments/components/mocha

In Terminal 1 . . .

Results in :

Unable to resolve some modules:

  "react/addons" in /home/yourself/projects/mantra-sample-blog-app/node_modules/enzyme/build/react-compat.js (web.browser)
  "react/lib/ReactContext" in /home/yourself/projects/mantra-sample-blog-app/node_modules/enzyme/build/react-compat.js (web.browser)
  "react/lib/ExecutionEnvironment" in /home/yourself/projects/mantra-sample-blog-app/node_modules/enzyme/build/react-compat.js (web.browser)

If you notice problems related to these missing modules, consider running:

  meteor npm install --save react             

Versions

you@yours:~$ npm --version
2.15.5
you@yours:~$ node --version
v4.4.5
you@yours:~$ meteor --version
Meteor 1.3.2.4
you@yours:~$ lsb_release -a
Distributor ID: Ubuntu
Description:  Ubuntu 16.04 LTS
Release:  16.04
Codename: xenial
you@yours:~$ 

@tmeasday
Copy link
Contributor

tmeasday commented Jun 20, 2016

Ok, reading up on this bug: enzymejs/enzyme#47 it seems like this is about Enzyme doing some conditional out of date requires for React < 15.

It's nothing to worry about, but it would be nice to remove the warning. @benjamn, any suggestions about whether there's any way to silence warnings about known missing conditionally require-ed modules?

In webpack-land the accepted solution seems to be externalizing those dependencies in your webpack config.

@hwillson hwillson assigned hwillson and unassigned tmeasday Oct 4, 2016
@RobinVanCauter
Copy link

RobinVanCauter commented Feb 15, 2017

Not sure what changed over the last couple of months, but pulling the react branch from this repo, installing npm dependencies and then running test-watch results in the console log included below(in the browser). The server console also shows the warning discussed in this issue.

The client side tests don't seem to run at all, so client-side testing is completely broken in the current state of the react branch.

When I remove the "import enzyme.. " line and the other enzyme references, the tests run without any issues.

So it seems this error is directly related to enzyme.

modules-runtime.js:459 Uncaught Error: Cannot find module 'crypto'
    at require (modules-runtime.js:119)
    at meteorInstall.node_modules.uuid.rng.js (modules.js:127395)
    at fileEvaluate (modules-runtime.js:191)
    at require (modules-runtime.js:116)
    at meteorInstall.node_modules.uuid.uuid.js (modules.js:127209)
    at fileEvaluate (modules-runtime.js:191)
    at require (modules-runtime.js:116)
    at meteorInstall.node_modules.enzyme.build.Utils.js (modules.js:84252)
    at fileEvaluate (modules-runtime.js:191)
    at require (modules-runtime.js:116)

@RobinVanCauter
Copy link

In case anyone is looking for a temporary solution, it seems a recent update of enzyme is what breaks the unit tests.

Version 2.4.1 works, version 2.7.1 breaks.

So setting the package.json entry to "=2.4.1" instead of "^2.4.1" fixes the unit tests.

@jaqua
Copy link

jaqua commented Mar 3, 2017

For me version 2.4.1 gives the same error...

@hwillson
Copy link
Contributor

React todos has been updated to use the latest and greatest from both react and enzyme, so this is no longer an issue. Thanks!

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

No branches or pull requests

6 participants