Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhantomJs: Can't find variable map

I receive the following error:

INFO [karma]: Karma v0.13.9 server started at http://localhost:9018/

INFO [launcher]: Starting browser PhantomJS

PhantomJS 1.9.8 (Mac OS X 0.0.0) ERROR
      ReferenceError: Can't find variable: Map
      at /Users/runtimeZero/code/vendor/inert/inert.min.js:589

I understand that I am including a file called inert.js which is using ES6 Map() . This is freaking out PhantomJs.

So I included core-js/es6/map.js polyfill in my karma config under files. However that does not resolve the issue.

Any tips ?

like image 420
runtimeZero Avatar asked Jan 18 '17 21:01

runtimeZero


Video Answer


2 Answers

I think PhatomJS is not supporting ES6 Map, so you need to try with a polyfill, I'm using babel polyfill npm install babel-polyfill --save-dev

files: [
    { pattern: 'node_modules/babel-polyfill/browser.js', instrument: false}, 
],
like image 81
jamesjara Avatar answered Oct 03 '22 05:10

jamesjara


you need to install es6-shim and add it to your files section in karma config file.

npm install es6-shim --save

in your karma.config.js add it to your list of files

files: [
    'node_modules/es6-shim/es6-shim.js'
]
like image 41
Sul Aga Avatar answered Oct 03 '22 05:10

Sul Aga