Sucharitha Suchi
Sucharitha Suchi

Reputation: 328

SyntaxError: Use of reserved word 'class' on implementing phantomjs in angular 8 application

I am trying to implement phantom js in angular 8 application by following below steps:

  1. npm install karma-phantomjs-launcher --save-dev
  2. npm install intl --save
  3. Add import 'core-js/client/shim'; and import intl; to polyfills.ts.

I am getting following syntax error on running ng test:

  SyntaxError: Use of reserved word 'class'
  at http://localhost:9876/_karma_webpack_/polyfills.js:22707:0

Kindly guide me for this issue. Thanks

Upvotes: 2

Views: 3244

Answers (2)

Jeremy
Jeremy

Reputation: 3809

Add the following to your polyfills.ts file:

import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';

Upvotes: 0

Ahmed Ghonim
Ahmed Ghonim

Reputation: 4780

Set the target in tsconfig.spec.json to es5 instead of the default es6

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/spec",
    "baseUrl": "./",
    "types": [
      "jasmine",
      "node"
    ],
    "target": "es5",  <<<========== add this line
  },

Upvotes: 3

Related Questions