deostroll
deostroll

Reputation: 11995

Can we sort test errors in mocha?

Assume I have a test file as follows:

describe('my tests', function() {
  it('t1 ...', cb);
  it('t2 ...', cb);
  it('t3 ...', cb);
  it('t4 ...', cb);
  // ...
})

Suppose I got errors in t2 and t3. My goal is to fix the error tests serially one after the other. So I have to fix t2 and then t3, and, so on.

But in the mocha report, the errors are sorted serially as how they occur in the test file. So t2 error is reported before t3, and, so on.

The problem is if there are many tests (10+) (it gets worse with very long stacktraces) I'd have to scroll a lot to find the first error (t2). I am looking at some command line switch which will report t2 to the end, and, all the later errors to the top.

Upvotes: 2

Views: 197

Answers (1)

jeeves
jeeves

Reputation: 2031

Not sure if it this is what you are looking for but you could try running mocha with the bail option. This will cause mocha to exit at the first test failure so that you only have to deal with one error at a time.

Upvotes: 1

Related Questions