mocha: XUnit Reporter Throws Fatal Error "test.isPending is not a function"

The XUnit reporter (/lib/reporters/xunit.js) fails on line 134 when attempting to call test.isPending(). The error reported is: Fatal error: test.isPending is not a function.

When I inspect the test object passed into XUnit.prototype.test, I do not see isPending defined on the object.

If I modify the else if condition to typeof test.isPending === 'function' && test.isPending(), all tests complete successfully and the XUnit report is written correctly.

What I cannot determine (at least not without a little help) is if this is a valid error or if this is a downstream effect caused by something my code is doing incorrectly.

I’m calling mocha from grunt-mocha for client side tests. If this is an upstream error on their side I’m happy to help track it down.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 20 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Cool; glad I could help. Thanks for the test code!

Can you narrow it down to a minimal test case that reproduces the issue? The XUnit reporter is working ok for me. As far as I’m aware, isPending is definitely supposed to be a function and not ignored by the reporter, but there could be some unusual failures that would try to report something that’s not a normal test. (In the meantime I will see if I can dig up the place I previously saw such failures. [EDIT:] Looks like I was thinking of a past issue with failures being thrown from hooks, but it’s fixed and they’re handled correctly now as far as I can tell, so we’ll definitely want some code that can reproduce this issue.)