fullstackreact / react-yelp-clone

Tutorial: Build a Yelp-clone in React
https://www.fullstackreact.com/articles/react-tutorial-cloning-yelp/
MIT License
840 stars 218 forks source link

None of the enzyme tests pass #12

Closed Joegrundman closed 8 years ago

Joegrundman commented 8 years ago

while running win10.

I came across this problem while building up from the tutorial, but decided to try running it from this repo to see where i may have gone wrong. I cloned this repo, ran npm install, made new .env, and then npm test:

I get exactly the same problem as I had when building up from the tutorial- all enzyme-based tests fail with for example:

6) "before each" hook for "has a Router component"
     <App />
     null is not an object (evaluating 'ReactInstrumentation.debugTool.onSetDisplayName')
ShallowComponentWrapper@C:/react/react-yelp-clone/tests.webpack.js:79151:34
_render@C:/react/react-yelp-clone/tests.webpack.js:79201:48
_batchedRender@C:/react/react-yelp-clone/tests.webpack.js:79183:20
batchedUpdates@C:/react/react-yelp-clone/tests.webpack.js:11314:16
batchedUpdates@C:/react/react-yelp-clone/tests.webpack.js:1175:35
render@C:/react/react-yelp-clone/tests.webpack.js:79176:31
render@C:/react/react-yelp-clone/tests.webpack.js:27705:44
C:/react/react-yelp-clone/tests.webpack.js:55934:33
perform@C:/react/react-yelp-clone/tests.webpack.js:3917:25
batchedUpdates@C:/react/react-yelp-clone/tests.webpack.js:11316:27
batchedUpdates@C:/react/react-yelp-clone/tests.webpack.js:1175:35
C:/react/react-yelp-clone/tests.webpack.js:55933:42
withSetStateAllowed@C:/react/react-yelp-clone/tests.webpack.js:45109:6
ShallowWrapper@C:/react/react-yelp-clone/tests.webpack.js:55932:39
shallow@C:/react/react-yelp-clone/tests.webpack.js:74201:42
C:/react/react-yelp-clone/tests.webpack.js:61263:36

if one changes the browser from Phantomjs to Chrome
then the error message is slightly different

Chrome 51.0.2704 (Windows 10 0.0.0) ERROR
  Uncaught TypeError: Cannot convert a Symbol value to a string
  at http://localhost:9876/context.js:64

I suspect there is an issue here with karma since i could successfully write a test using just enzyme and mocha.

ddroche commented 8 years ago

@Joegrundman I had the same problem and have gotten it to work. I didn't spend the time to figure out which package is the problem, but if you use the exact same versions of all the packages in this repo in your own code, it works.

Joegrundman commented 8 years ago

Hi ddroche thank you for the response, actually I have found the problem to be the react/react-dom/react-addons-test-utils 15.2.1 release. If it is rolled back to 15.2.0 it works fine. My guess is that it is in the utils-package. I have posted an issue on airbnb/enzyme about this

Joegrundman commented 8 years ago

I can now give a definitive response with thanks to @nfcampos at airbnb.

As of react15.2.1, Test utils cannot be run in production mode. This webpack setup has production config , development config and test config, but test config does not share development config

so:

in webpack.config. line 21:

isDev: isDev

change to

isDev: isDev || isTest

auser commented 8 years ago

Thanks for the update. I will update the webpack config to handle this case.

auser commented 8 years ago

Fixed this in the latest commit.

Thanks for reporting!