Failed to Parse error : Unexpected token on "import" with Istanbul

680 Views Asked by At

I am using Istanbul for code coverage of Protractor Tests.

In the process of Instrumenting the source Code I am getting a "Failed to parse, Unexpected Token" error, and after going through the error it is found that the "import" token is creating the issue.

Been working on Angular2 and Typescript.

I am using command : istanbul instrument ./dir/to/instrument/ -o ./out/dir/

Istanbul by default uses esprima parser to parse the code before instrumenting. This is a parsing error, but I am unable to find any solution to resolve it.

Istanbul:v0.4.5

Esprima parser:v3.1.3

1

There are 1 best solutions below

1
On

Use this command:

npx nyc instrument [input-file] [output-file]