4

I am using Chai.js on Node. The line console.log(e) where e is an exception thrown by Chai.js print something like expected a to be within 0..3. How can I make the exception of Chai.js include stack trace info?

2 Answers 2

6

I found the answer. I can config chai to enable stack trace. Here's the code on assertion styles page of chai.

var chai = require('chai');
chai.Assertion.includeStack = true; // defaults to false
Sign up to request clarification or add additional context in comments.

2 Comments

It's chai.config.includeStack = true; as of Chai version 1.9.1 released on 2014-03-19. See relevant Chai release notes for more information.
In what file would you put this?
0

I don't use Chai.JS. But if e is an Error object, you can use the property stack of the object to get the stack trace.

The core module "util" may also help you : http://nodejs.org/api/util.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.