lundi 10 juillet 2017

When testing Promises with Mocha, how can I print the full stack trace when an error occurs

Suppose I have a small spec like:

describe("feature", () => {
  it("does stuff", () => {
    return myPromiseBasedFn().then(result => {
      expect(result).to.eql(1);
    });
  });
});

Currently, when the promise is rejected, I just see the error message. For example:

12 passing (88ms)
1 failing

1) feature does stuff:
   TypeError: Cannot read property 'method' of undefined

How can I make mocha print the full stack trace of this error? For example, I'd like to see

TypeError: Cannot read property 'method' of undefined
    at SomeFunc (code/file.js:12:32)
    at code/base.js:49:24

Aucun commentaire:

Enregistrer un commentaire