tntim96 / JSCover

JSCover is a JavaScript Code Coverage Tool that measures line, branch and function coverage
GNU General Public License v2.0
399 stars 84 forks source link

ES6 - "let" not supported #246

Closed cobexer closed 7 years ago

cobexer commented 7 years ago

According to the ES6 Support table you linked to in https://github.com/tntim96/JSCover/issues/224#issuecomment-274945470 I tried to use the ES6 feature "let" but that did not work at all:

In the jscover log I get (with -ws and --log=FINEST):

20170222 14:49:42.011,92,INFO,"Instrumenting /js/list.js",jscover.instrument.InstrumenterService,
20170222 14:49:42.030,92,FINE,"Sending response status:500 Internal Server Error mime:text/plain",jscover.server.HttpServer,

In other words: No useful error message. My CI doesn't capture error response text either of course... so after some digging I built an environment where I could experiment and can reproduce the error with a simple file containing:

let x = 0;
org.mozilla.javascript.EvaluatorException: missing ; before statement (/js/x.js#1)
    at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:77)
    at org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:64)
    at org.mozilla.javascript.Parser.addError(Parser.java:188)
    at org.mozilla.javascript.Parser.addError(Parser.java:166)
    at org.mozilla.javascript.Parser.reportError(Parser.java:256)
    at org.mozilla.javascript.Parser.reportError(Parser.java:243)
    at org.mozilla.javascript.Parser.reportError(Parser.java:236)
    at org.mozilla.javascript.Parser.autoInsertSemicolon(Parser.java:1100)
    at org.mozilla.javascript.Parser.statementHelper(Parser.java:1077)
    at org.mozilla.javascript.Parser.statement(Parser.java:934)
    at org.mozilla.javascript.Parser.parse(Parser.java:573)
    at org.mozilla.javascript.Parser.parse(Parser.java:511)
    at jscover.instrument.SourceProcessor.instrumentSource(SourceProcessor.java:442)
    at jscover.instrument.SourceProcessor.processSourceWithoutHeader(SourceProcessor.java:420)
    at jscover.instrument.SourceProcessor.processSource(SourceProcessor.java:408)
    at jscover.instrument.SourceProcessor.processSourceForServer(SourceProcessor.java:396)
    at jscover.instrument.InstrumenterService.instrumentJSForWebServer(InstrumenterService.java:365)
    at jscover.server.InstrumentingRequestHandler.handleGet(InstrumentingRequestHandler.java:469)
    at jscover.server.HttpServer.run(HttpServer.java:416)

I currently use:

+--- com.github.tntim96:JSCover:1.0.26-SNAPSHOT
     \--- org.mozilla:rhino:1.7.7.1

and according to http://mozilla.github.io/rhino/compat/engines.html this should work.

tntim96 commented 7 years ago

Try adding the JavaScript version switch --js-version=1.8 as documented.