coveraje/coveraje — Issue #25: Can't register an Error event to determine what went wrong
Author: goatslacker
Created: 2012-03-10 02:28:21+00:00
State: open

Related to GH-24

`cover.js` in that example, will not tell me what went wrong. It will fail silently.

Ideally, I could do:

var instance = coveraje.cover(
"console.log('1'); var foo = require('./hi.js'); console.log('2');",
function (context, inst) {
console.log(context.module.exports);
},
{ globals: "node", colorizeShell: false }
);

instance.on('error', function (err) {
// do whatever i want with err.
});

or use the `onError` callback, whatever.

For this to work though, the [`runInConsole()`](https://github.com/coveraje/coveraje/blob/master/lib/node-coveraje.js#L79) function would need to be deferred.

Alternatively, if the API were restructured it could look something like:

var cover = new Coveraje({ global: "node" });
cover.on('error', function () { });
cover.on('done', function () {
// \o/ We're done!
});

// context is returned from this function.
var context = cover.run(fs.readFileSync('etc.js'));

Thoughts?