Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,4 @@ The following convenience methods are made available on all haunt objects. You c
+ issue.files[*].comment - (accepts an comment and line number) comment on a given line number in a diff of a pull-request
+ issue.files[*].comments[*].reply - (accepts a string) reply to a comment in a diff on a pull request
+ issue.reportFailures - generic test failure message, which notifies a user what failed based on mocha reporter.
+ issue.assertsFailed - only return assertion errors or false if no assertion errors occurred (will ignore runtime errors)
2 changes: 1 addition & 1 deletion bin/haunt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ console.log('Please provide your github credentials:'.yellow);

prompt.start();

var schema = {
var schema = {
properties: {
username: {
pattern: /^[a-zA-Z\s\-]+$/,
Expand Down
4 changes: 2 additions & 2 deletions examples/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
},

'after': function (pull) {
if (pull.reporter.stats.failures) {
if (pull.assertsFailed()) {
pull.reportFailures(pull.close.bind(pull))
}
}
Expand All @@ -53,7 +53,7 @@ module.exports = {
},

'after': function (issue) {
if (issue.reporter.stats.failures) {
if (issue.assertsFailed()) {
issue.reportFailures(issue.close.bind(issue))
}
}
Expand Down
8 changes: 8 additions & 0 deletions lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ Helper.prototype.reportFailures = function (callback) {
github.commentOnIssue(this.repo.owner.login, this.repo.name, this.number, body, callback);
}

// only return assertion errors, if none return false
Helper.prototype.assertsFailed = function() {
var fails = this.reporter.failures.filter(function(err) {
if (err.err.name === "AssertionError") return err;
});
return fails.length > 0 ? fails : false;
}

module.exports = Helper;
2 changes: 1 addition & 1 deletion lib/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Repo.prototype.spook = function (callback) {
issue.exports.reporter = reporter;

runner.run(function () {
if (reporter.stats.failures) {
if (issue.exports.assertsFailed()) {
total['failing-' + Repo.typeMap[type]]++;
}
next();
Expand Down