dvdzkwsk / react-redux-starter-kit

Get started with React, Redux, and React-Router.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when running `npm test` in CircleCI

EwanValentine opened this issue · comments

I have an application built using this starter kit, which all works locally fine. However, when I run npm test as part of my build, I'm getting a strange error which seems to originate from PhantomJS


START:
PhantomJS 2.1.1 (Linux 0.0.0) ERROR
  ReferenceError: Can't find variable: Symbol
  at webpack:///~/zen-observable-ts/lib/zenObservable.js:394:0 <- tests/test-bundler.js:76335
PhantomJS 2.1.1 (Linux 0.0.0) ERROR
  ReferenceError: Can't find variable: Symbol
  at webpack:///~/zen-observable-ts/lib/zenObservable.js:394:0 <- tests/test-bundler.js:76335

Same here, it's coming from an ES6 for of iterator.

It looks like PhantomJS needs to be polyfilled, I didn't manage to make it work yet.

Glad it's not just me! I've tried a few different versions of node without any luck. I've had to skip tests on build for now which is obviously not ideal...

Try installing es6-symbol and es5-ext then adding this to the file normalize.js, it worked for me

// 4) Symbol
// ------------------------------------
// PhantomJS doesn't implement ES6 for.. of loops
if (typeof Symbol === 'undefined') {
  require('es6-symbol/implement')
}

if (typeof [][Symbol.iterator] === 'undefined') {
  require('es5-ext/array/#/@@iterator/implement')
}

The idea is to polyfill Symbol and array[Symbol.iterator] that for..of loops require

Thanks @amangeot!

I realize I'm super late to the party, but for fixes like this I've opened up #1331 to accept new contributors, if any of you are interested.