Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_$jscoverage is not defined | blanket 1.2.1 #554

Open
NedalKouissi opened this issue Feb 5, 2016 · 21 comments
Open

_$jscoverage is not defined | blanket 1.2.1 #554

NedalKouissi opened this issue Feb 5, 2016 · 21 comments

Comments

@NedalKouissi
Copy link

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

@NedalKouissi
Copy link
Author

@alex-seville, what up brother !

@thom4parisot
Copy link

I encountered this issue as well and reverted to 1.1.9 too to make it work.

@westy92
Copy link

westy92 commented Feb 11, 2016

I just experienced this same error. What are you reverting to version 1.9.1?

@NedalKouissi
Copy link
Author

@westy92 npm install --save-dev blanket@1.9.1, you may need sudo :)

@westy92
Copy link

westy92 commented Feb 12, 2016

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?

@NedalKouissi
Copy link
Author

@westy92 yes you're right!

@alex-seville
Copy link
Owner

I've published a new version, 1.2.2. Let me know if it changes anything.

@thom4parisot
Copy link

Hm sadly I still encounter the issue with node@0.10. 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:

├─┬ blanket@1.2.2
│ ├── acorn@1.2.2
│ ├─┬ falafel@1.2.0
│ │ └── acorn@1.2.2
│ ├── foreach@2.0.5
│ ├── isarray@0.0.1
│ └── object-keys@1.0.9

@ufocoder
Copy link

+1

@alex-seville
Copy link
Owner

Hmm, it's working on travis CI at node@0.10 - https://travis-ci.org/alex-seville/blanket/jobs/110242642

@vaunus
Copy link

vaunus commented Feb 26, 2016

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.

@alex-seville
Copy link
Owner

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

@vaunus
Copy link

vaunus commented Feb 26, 2016

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

@abienkowski
Copy link

This is has been around for a long time, originally report Dec.2013.

I need to run npm install blanket@1.1.6 to make my tests run.

@markvandenbrink
Copy link

Same problem here (_$jscoverage is not defined) when using 1.2.1 or 1.2.2. Reverting back to 1.1.9 as workaround.

@frankred
Copy link

Same with me...

1 similar comment
@sbefort
Copy link

sbefort commented Apr 24, 2016

Same with me...

@rlk833
Copy link

rlk833 commented May 6, 2016

Same here. Busted. We absolutely need ecmaVersion 6. Tried going to a lower version and other problems occur because of no ecmaVersion 6 support.

@kousha-icracked
Copy link

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?

mauritsl added a commit to mauritsl/bluegate that referenced this issue Jul 11, 2016
@rbudiharso
Copy link

I'm having this problem too with blanket 1.2.3

thom4parisot added a commit to thom4parisot/tld.js that referenced this issue Sep 13, 2016
thom4parisot pushed a commit to thom4parisot/tld.js that referenced this issue Sep 13, 2016
* Do not require end-users to have `npm@2`

* Use xvfb-run and test on more recent Node platforms

* Update tests (.eu has changed)

* Embed updated rules

* Do not try to build `node@7`

* Revert to `blanket@1.1.9`

refs alex-seville/blanket#554
thom4parisot added a commit to bbc/slayer that referenced this issue Sep 21, 2016
@selfagency
Copy link

selfagency commented Jan 27, 2017

I too am having this problem with 1.2.3 using es6

> nylon-web@2.5.0 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

mdsummers added a commit to mdsummers/async-lock that referenced this issue Oct 16, 2017
blanket 1.1.10 and above gives the error "_$jscoverage is not defined"
when running the test suite. More details on the error are available at:

alex-seville/blanket#554

Use version 1.1.9 which is not affected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests