lathonez / clicker

Ionic 2 + @angular/cli Seed Project : Angular2 + Typescript + Karma + Protractor + Travis
http://lathonez.com/2018/ionic-2-unit-testing/
MIT License
430 stars 137 forks source link

Phantom browser: Can't find variable: Map #247

Closed ws-hofshteyn closed 7 years ago

ws-hofshteyn commented 7 years ago

Hey! I needed to launch test in docker container and I needed to set up PhantomJS instead Chrome.

I set up karma-phantomjs-launcher, include it in karma.conf.js into the plugin list array, point browser [PhantomJS] as well. And I had an error that looked like this (all tests worked with Chrome well):

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR ReferenceError: Can't find variable: Map at webpack:///~/@angular/core/@angular/core.es5.js:1502:0 <- src/test.ts:1781

So after research I found that I need to implement parts of es-6 to the test.ts file before import zone.js.

import 'core-js/es6'; import 'core-js/es7/reflect';

And my tests works perfect!

lathonez commented 7 years ago

Thanks a lot for the info. I don't use Phantom any more, even in docker or CI, too many issues like this!

However I know some people are forced to use it - so this is definitely useful for them.

This would probably useful as a PR or an issue against ng-cli, as I imagine it is a problem there if we are finding it here.

Thanks,

Stephen