Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k
stars
787
forks
source link
Getting a syntax error running against my test suite #774
I am attempting to add Istanbul coverage to my FPO project. The qunit test suite runs fine by itself, both in node and the browser.
But when I try to run:
istanbul cover scripts/node-tests.js
...as indicated in Istanbul's docs, I get a syntax error reported:
/tmp/fpo/src/fpo.src.js:9
__cov_Vf8WSGguAYwRyy_6PrvS4A.s['1']++;(function UMD(name,context,definition){__cov_Vf8WSGguAYwRyy_6PrvS4A.f['1']++;__cov_Vf8WSGguAYwRyy_6PrvS4A.s['2']++;if((__cov_Vf8WSGguAYwRyy_6PrvS4A.b['2'][0]++,typeof define==='function')&&(__cov_Vf8WSGguAYwRyy_6PrvS4A.b['2'][1]++,define.amd)){__cov_Vf8WSGguAYwRyy_6PrvS4A.b['1'][0]++;__cov_Vf8WSGguAYwRyy_6PrvS4A.s['3']++;define(definition);}else{__cov_Vf8WSGguAYwRyy_6PrvS4A.b['1'][1]++;__cov_Vf8WSGguAYwRyy_6PrvS4A.s['4']++;if((__cov_Vf8WSGguAYwRyy_6PrvS4A.b['4'][0]++,typeof module!=='undefined')&&(__cov_Vf8WSGguAYwRyy_6PrvS4A.b['4'][1]++,module.exports)){__cov_Vf8WSGguAYwRyy_6PrvS4A.b['3'][0]++;__cov_Vf8WSGguAYwRyy_6PrvS4A.s['5']++;module.exports=definition();}else{__cov_Vf8WSGguAYwRyy_6PrvS4A.b['3'][1]++;__cov_Vf8WSGguAYwRyy_6PrvS4A.s['6']++;context[name]=definition(name,context);}}}('FPO',this,function DEF(name,context){'use strict';__cov_Vf8WSGguAYwRyy_6PrvS4A.f['2']++;__cov_Vf8WSGguAYwRyy_6PrvS4A.s[
SyntaxError: Unexpected token :
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/istanbul/lib/hook.js:107:24)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/tmp/fpo/scripts/node-tests.js:9:355)
As you can see that code is entirely valid (ES5 even). AFAICT, it's fairly standard UMD style code. I'm not sure which : the syntax error's message is complaining about.
Other parts of that file use ES6, but it's all simple stuff and I can't see anything that would be interfering with the Esprima parsing that Istanbul does. I even ran the entire file through Esprima's online code parser and it parsed fine.
Any thoughts? Apologies if this is a known issue. I tried searching through issues, but there's a lot there and I couldn't sort out which ones to look at or not.
I am attempting to add Istanbul coverage to my FPO project. The qunit test suite runs fine by itself, both in node and the browser.
But when I try to run:
...as indicated in Istanbul's docs, I get a syntax error reported:
The beginning few lines of that file being complained about are:
As you can see that code is entirely valid (ES5 even). AFAICT, it's fairly standard UMD style code. I'm not sure which
:
the syntax error's message is complaining about.Other parts of that file use ES6, but it's all simple stuff and I can't see anything that would be interfering with the Esprima parsing that Istanbul does. I even ran the entire file through Esprima's online code parser and it parsed fine.
Any thoughts? Apologies if this is a known issue. I tried searching through issues, but there's a lot there and I couldn't sort out which ones to look at or not.