I\'m using Angular 4, Webpack 2.4.1, Karma 1.6 and Jasmine 2.6.1 and am writing ES2015 not TypeScript
I\'ve got a tiny angular demo app and I want to
This is what has worked for me: I was using PhantonJs with karma and nightwatch for my testing . I was getting this error during JhantomJs initialization and as test were getting started because because there's no Map in browsers. PhantomJS is used as Karma driver, and it doesn't support ES6 features.
I tried to load polyfills but that did not help as well. Then I saw that support for PhantonJs has long gone and felt it wont work. So I took an effort to replace PhantomJs with Chrome headless browser and surprisingly it was pretty easy to replace.
Here are the thing I did to make the change from PhantomJs to Chrome headless:
const puppeteer = require('puppeteer');
process.env.CHROME_BIN = puppeteer.executablePath();
module.exports = function(config) {
config.set({
.
browsers: ['ChromeHeadless'],
.
});
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"args": ["--no-sandbox", "headless"]
}
}
This is something which has worked for me; may or may not work for you depending on the kind of side things you are using with JhantomJs for testing. Nevertheless should helpful for anyone who is trying to move away PhantomJs.
This error is thrown because there's no Map
in browsers. PhantomJS is used as Karma driver, and it doesn't support ES6 features.
If polyfills (e.g. core-js
) aren't loaded in files that were included in tests, they should be loaded separately, for example via karma-es6-shim plugin:
...
frameworks: ['es6-shim', 'jasmine'],
...