_$jscoverage is not defined | blanket 1.2.1
I'm using blanket 1.2.1 with mocha, it gives me this error ! i must downgrade to 1.1.9 to make it work :'(
Snippets from Package.json
"scripts": { "test": "mocha && mocha --require blanket -R html-cov > coverage.html" }, "config": { "blanket": { "pattern": "index.js", "data-cover-never": ["node_modules", "test"] } }
The error
Error: BLANKET-Error parsing instrumented code: ReferenceError: _$jscoverage is not defined at /home/idsfn/Documents/training/mochaGettingStarted/node_modules/blanket/src/index.js:177:37 at Object.__dirname.blanket._blanket.instrument (/home/idsfn/Documents/training/mochaGettingStarted/node_modules/blanket/src/blanket.js:126:17) at Object.require.extensions..js (/home/idsfn/Documents/training/mochaGettingStarted/node_modules/blanket/src/index.js:158:25) at Module.load (module.js:344:32) at Function.Module._load (module.js:301:12) at Module.require (module.js:354:17) at require (internal/module.js:12:17) at Object.<anonymous> (/home/idsfn/Documents/training/mochaGettingStarted/test/index.js:4:12) at Module._compile (module.js:410:26) at Module._extensions..js (module.js:417:10) at Object.require.extensions..js (/home/idsfn/Documents/training/mochaGettingStarted/node_modules/blanket/src/index.js:144:17) at Module.load (module.js:344:32) at Function.Module._load (module.js:301:12) at Module.require (module.js:354:17) at require (internal/module.js:12:17) at /home/idsfn/Documents/training/mochaGettingStarted/node_modules/mocha/lib/mocha.js:219:27 at Array.forEach (native) at Mocha.loadFiles (/home/idsfn/Documents/training/mochaGettingStarted/node_modules/mocha/lib/mocha.js:216:14) at Mocha.run (/home/idsfn/Documents/training/mochaGettingStarted/node_modules/mocha/lib/mocha.js:468:10) at Object.<anonymous> (/home/idsfn/Documents/training/mochaGettingStarted/node_modules/mocha/bin/_mocha:403:18) at Module._compile (module.js:410:26) at Object.Module._extensions..js (module.js:417:10) at Module.load (module.js:344:32) at Function.Module._load (module.js:301:12) at Function.Module.runMain (module.js:442:10) at startup (node.js:136:18) at node.js:966:3
@alex-seville, what up brother !
I encountered this issue as well and reverted to 1.1.9 too to make it work.
I just experienced this same error. What are you reverting to version 1.9.1?
@westy92 npm install --save-dev [email protected], you may need sudo :)
If 1.2.1 is the latest version, how can 1.9.1 exist? Something doesn't add up. Do you mean 1.1.9?
@westy92 yes you're right!
I've published a new version, 1.2.2. Let me know if it changes anything.
Hm sadly I still encounter the issue with [email protected]. Here is the trace:
> mocha -r env-test -r blanket -R html-cov test/*.js > coverage.html
/Users/oncletom/workspace/freebird/feed-parser/node_modules/blanket/src/index.js:179
throw e;
^
Error: BLANKET-Error parsing instrumented code: ReferenceError: _$jscoverage is not defined
at /Users/oncletom/workspace/freebird/feed-parser/node_modules/blanket/src/index.js:177:37
at Object.__dirname.blanket._blanket.instrumentSync (/Users/oncletom/workspace/freebird/feed-parser/node_modules/blanket/src/blanket.js:134:21)
at Object.__dirname.blanket._blanket.instrument (/Users/oncletom/workspace/freebird/feed-parser/node_modules/blanket/src/blanket.js:141:22)
at Object.require.extensions..js (/Users/oncletom/workspace/freebird/feed-parser/node_modules/blanket/src/index.js:158:25)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/oncletom/workspace/freebird/feed-parser/test/parse-feed.js:3:11)
at Module._compile (module.js:410:26)
at Module._extensions..js (module.js:417:10)
at Object.require.extensions..js (/Users/oncletom/workspace/freebird/feed-parser/node_modules/blanket/src/index.js:144:17)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at /Users/oncletom/workspace/freebird/feed-parser/node_modules/mocha/lib/mocha.js:219:27
at Array.forEach (native)
at Mocha.loadFiles (/Users/oncletom/workspace/freebird/feed-parser/node_modules/mocha/lib/mocha.js:216:14)
at Mocha.run (/Users/oncletom/workspace/freebird/feed-parser/node_modules/mocha/lib/mocha.js:468:10)
at Object.<anonymous> (/Users/oncletom/workspace/freebird/feed-parser/node_modules/mocha/bin/_mocha:403:18)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
And a partial npm ls:
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
+1
Hmm, it's working on travis CI at [email protected] - https://travis-ci.org/alex-seville/blanket/jobs/110242642
Same issue here when trying to use "use strict"; at the top of some of my project files using blanket 1.2.2.
A very simple example of this: test.js:
let abc = 123;
Error: BLANKET-Error parsing instrumented code: SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
Fine, so I add use strict: test.js:
'use strict';
let abc = 123;
And the output:
# mocha --require blanket test.js
/Volumes/workspace/sss/mobile-api/node_modules/blanket/src/index.js:179
throw e;
^
Error: BLANKET-Error parsing instrumented code: ReferenceError: _$jscoverage is not defined
at /Volumes/workspace/sss/mobile-api/node_modules/blanket/src/index.js:177:37
at Object.__dirname.blanket._blanket.instrumentSync (/Volumes/workspace/sss/mobile-api/node_modules/blanket/src/blanket.js:134:21)
at Object.__dirname.blanket._blanket.instrument (/Volumes/workspace/sss/mobile-api/node_modules/blanket/src/blanket.js:141:22)
at Object.require.extensions..js (/Volumes/workspace/sss/mobile-api/node_modules/blanket/src/index.js:158:25)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at /Volumes/workspace/sss/mobile-api/node_modules/mocha/lib/mocha.js:219:27
at Array.forEach (native)
at Mocha.loadFiles (/Volumes/workspace/sss/mobile-api/node_modules/mocha/lib/mocha.js:216:14)
at Mocha.run (/Volumes/workspace/sss/mobile-api/node_modules/mocha/lib/mocha.js:468:10)
at Object.<anonymous> (/Volumes/workspace/sss/mobile-api/node_modules/mocha/bin/_mocha:403:18)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:141:18)
at node.js:933:3
Snippet from my package.json:
"blanket": {
"pattern": "///[\\w-_]+\\.js$/",
"data-cover-never": [
"/node_modules/",
"/test/"
],
"data-cover-ecmaVersion": 6,
"data-cover-reporter-options": {
"relativepath": true
}
}
Tested on various versions of Node 4 and 5.
Sounds like you're using ES6, you'll need to let Blanket know: https://github.com/alex-seville/blanket/blob/master/docs/options.md#data-cover-ecmaversion
I have already let Blanket know I'm using ES6. See the snippet from my package.json above which has the "data-cover-ecmaVersion": 6 parameter.
We are using ES6 throughout our codebase but have had to wrap most ES6 files in a function wrapper to get Blanket to work. This doesn't work for top-level files however such as app.js. As soon as I add "use strict"; to this I get this error so we are unable to use ES6 features in these files.
I can reproduce this in a simple example: test.js:
var abc = 123;
mocha --require blanket test.js
0 passing (2ms)
However: test.js:
'use strict';
var abc = 123;
# mocha --require blanket test.js
/usr/local/lib/node_modules/blanket/src/index.js:179
throw e;
^
Error: BLANKET-Error parsing instrumented code: ReferenceError: _$jscoverage is not defined
at /usr/local/lib/node_modules/blanket/src/index.js:177:37
at Object.__dirname.blanket._blanket.instrumentSync (/usr/local/lib/node_modules/blanket/src/blanket.js:134:21)
at Object.__dirname.blanket._blanket.instrument (/usr/local/lib/node_modules/blanket/src/blanket.js:141:22)
at Object.require.extensions..js (/usr/local/lib/node_modules/blanket/src/index.js:158:25)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at /usr/local/lib/node_modules/mocha/lib/mocha.js:219:27
at Array.forEach (native)
at Mocha.loadFiles (/usr/local/lib/node_modules/mocha/lib/mocha.js:216:14)
at Mocha.run (/usr/local/lib/node_modules/mocha/lib/mocha.js:468:10)
at Object.<anonymous> (/usr/local/lib/node_modules/mocha/bin/_mocha:403:18)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:141:18)
at node.js:933:3
This is has been around for a long time, originally report Dec.2013.
I need to run npm install [email protected] to make my tests run.
Same problem here (_$jscoverage is not defined) when using 1.2.1 or 1.2.2. Reverting back to 1.1.9 as workaround.
Same with me...
Same with me...
Same here. Busted. We absolutely need ecmaVersion 6. Tried going to a lower version and other problems occur because of no ecmaVersion 6 support.
I'm having the same problem when using ES6. Running 1.1.9 causes another problem:
Error: BLANKET-Error parsing instrumented code: Error: BLANKET-Error parsing instrumented code: Error: BLANKET-Error parsing instrumented code: Error: Line 17: Unexpected token )
Anyone has a solution?
I'm having this problem too with blanket 1.2.3
I too am having this problem with 1.2.3 using es6
> [email protected] test /Users/ds/Dev/nylon-web
> multi='dot=- html-cov=coverage.html' ./node_modules/mocha/bin/mocha -r blanket --reporter mocha-multi --no-colors "src/app/app.js"
/Users/ds/Dev/nylon-web/node_modules/blanket/src/index.js:180
throw e;
^
Error: BLANKET-Error parsing instrumented code: ReferenceError: _$jscoverage is not defined
at /Users/ds/Dev/nylon-web/node_modules/blanket/src/index.js:178:37
at Object.__dirname.blanket._blanket.instrumentSync (/Users/ds/Dev/nylon-web/node_modules/blanket/src/blanket.js:134:21)
at Object.__dirname.blanket._blanket.instrument (/Users/ds/Dev/nylon-web/node_modules/blanket/src/blanket.js:141:22)
at Object.require.extensions..js (/Users/ds/Dev/nylon-web/node_modules/blanket/src/index.js:159:25)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at /Users/ds/Dev/nylon-web/node_modules/mocha/lib/mocha.js:222:27
at Array.forEach (native)
at Mocha.loadFiles (/Users/ds/Dev/nylon-web/node_modules/mocha/lib/mocha.js:219:14)
at Mocha.run (/Users/ds/Dev/nylon-web/node_modules/mocha/lib/mocha.js:487:10)
at Object.<anonymous> (/Users/ds/Dev/nylon-web/node_modules/mocha/bin/_mocha:459:18)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:148:18)
at node.js:405:3