Hacker News new | ask | show | jobs
by ghayes 1649 days ago
Since you're here, and the online docs are currently missing, do you know the best way to a stacktrace from a failed Chai assertion? Basically, if I do:

    import chai from 'chai';
    chai.config.includeStack = true;
    try {
      chai.expect(1).to.equals(2);
    } catch (e) {
      console.log(e.stack);
    }
In the REPL, I'm getting `e` as an AssertionError with a trace, but in my running code, the error is coming back as a vanilla object without a stacktrace. Sorry that this is clearly not the right forum for this kind of question.
1 comments

Failed expectations always throw an AssertionError, and they always have a stack. It might be the test runner you have which is breaking or hiding the stack?
Thanks; figured it out. I was passing the object to a parent thread and the class properties were being removed in the process. Thanks for the help.