Skip to content

Instantly share code, notes, and snippets.

@akiellor
Created February 6, 2015 03:46
Show Gist options
  • Save akiellor/12db63d9b578447b9aed to your computer and use it in GitHub Desktop.
Save akiellor/12db63d9b578447b9aed to your computer and use it in GitHub Desktop.
Mocha/Promise error detection.
var falafel = require('falafel');
var fs = require('fs');
var file = process.argv[2];
var src = fs.readFileSync(file).toString();
var output = falafel(src, {loc: true}, function (node) {
if (node.type === 'Identifier' && node.name === "it") {
var testBody = node.parent.arguments[1].body.body
var lastStatement = testBody[testBody.length - 1];
if(lastStatement.type !== 'ReturnStatement') {
console.log(file + ":" + lastStatement.loc.start.line);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment