alex-seville / blanket

blanket.js is a simple code coverage library for javascript. Designed to be easy to install and use, for both browser and nodejs.
http://blanketjs.org
Other
1.4k stars 177 forks source link

ES6 features requiring "use strict" fails while instrumenting #525

Open cosmosgenius opened 9 years ago

cosmosgenius commented 9 years ago

I am running node v4.0.0 on windows 10 x64 using mocha as the test runner. The code executes fine on node as well as mocha tests are passing when not running with blanket.

File: db.js

"use strict"
let mongoose = require("mongoose");
module.export = mongoose;

Error:

d:\Projects\github\webhooked\node_modules\blanket\src\index.js:167
                            throw new Error("BLANKET-Error parsing instrumented code: "+err);
                            ^

Error: BLANKET-Error parsing instrumented code: Error: BLANKET-Error parsing instrumented code: SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at d:\Projects\github\webhooked\node_modules\blanket\src\index.js:167:35
    at Object.__dirname.blanket._blanket.instrument (d:\Projects\github\webhooked\node_modules\blanket\src\blanket.js:125:17)
    at Object.require.extensions..js (d:\Projects\github\webhooked\node_modules\blanket\src\index.js:148:25)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (d:\Projects\github\webhooked\tests\model.app.js:5:10)
    at Module._compile (module.js:434:26)
    at Module._extensions..js (module.js:452:10)
    at Object.require.extensions..js (d:\Projects\github\webhooked\node_modules\blanket\src\index.js:172:17)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at d:\Projects\github\webhooked\node_modules\mocha\lib\mocha.js:216:27
    at Array.forEach (native)
    at Mocha.loadFiles (d:\Projects\github\webhooked\node_modules\mocha\lib\mocha.js:213:14)
    at Mocha.run (d:\Projects\github\webhooked\node_modules\mocha\lib\mocha.js:453:10)
    at Object.<anonymous> (d:\Projects\github\webhooked\node_modules\mocha\bin\_mocha:401:18)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)
    at startup (node.js:117:18)
    at node.js:951:3
gjurgens commented 8 years ago

I've just made a pull request (#530) with a proposed fix for this problem. Hope it helps!