2013-09-17 21:22:36 +00:00
|
|
|
describe('configuration', function () {
|
2012-11-29 08:18:48 +00:00
|
|
|
var assert = chai.assert;
|
2012-02-22 18:43:44 +00:00
|
|
|
|
2012-11-29 08:18:48 +00:00
|
|
|
function fooThrows () {
|
2014-01-18 16:48:48 +00:00
|
|
|
chai.expect('foo').to.be.equal('bar');
|
2012-11-29 08:18:48 +00:00
|
|
|
}
|
2012-02-22 18:43:44 +00:00
|
|
|
|
2013-09-17 21:22:36 +00:00
|
|
|
it('Assertion.includeStack is true', function () {
|
2013-02-03 23:03:40 +00:00
|
|
|
var orig = chai.Assertion.includeStack;
|
2012-02-22 18:43:44 +00:00
|
|
|
chai.Assertion.includeStack = true;
|
2013-02-03 23:03:40 +00:00
|
|
|
|
2012-02-22 18:43:44 +00:00
|
|
|
try {
|
|
|
|
fooThrows();
|
|
|
|
assert.ok(false, 'should not get here because error thrown');
|
|
|
|
} catch (err) {
|
2013-02-03 23:03:40 +00:00
|
|
|
chai.Assertion.includeStack = orig;
|
|
|
|
// not all browsers support err.stack
|
|
|
|
if ('undefined' !== typeof err.stack) {
|
2014-01-18 16:48:48 +00:00
|
|
|
assert.include(err.stack, 'assertEqual', 'should have internal stack trace in error message');
|
|
|
|
assert.include(err.stack, 'fooThrows', 'should have user stack trace in error message');
|
2012-02-22 22:45:42 +00:00
|
|
|
}
|
2012-02-22 18:43:44 +00:00
|
|
|
}
|
2013-02-03 23:03:40 +00:00
|
|
|
|
2012-02-22 18:43:44 +00:00
|
|
|
});
|
|
|
|
|
2013-09-17 21:22:36 +00:00
|
|
|
it('Assertion.includeStack is false', function () {
|
2013-02-03 23:03:40 +00:00
|
|
|
var orig = chai.Assertion.includeStack;
|
2012-02-22 18:43:44 +00:00
|
|
|
chai.Assertion.includeStack = false;
|
2013-02-03 23:03:40 +00:00
|
|
|
|
2012-02-22 18:43:44 +00:00
|
|
|
try {
|
|
|
|
fooThrows();
|
|
|
|
assert.ok(false, 'should not get here because error thrown');
|
|
|
|
} catch (err) {
|
2013-02-03 23:03:40 +00:00
|
|
|
chai.Assertion.includeStack = orig;
|
|
|
|
|
2012-06-26 16:35:41 +00:00
|
|
|
// IE 10 supports err.stack in Chrome format, but without
|
|
|
|
// `Error.captureStackTrace` support that allows tuning of the error
|
|
|
|
// message.
|
2014-01-18 16:48:48 +00:00
|
|
|
if ('undefined' !== typeof err.stack && 'undefined' !== typeof Error.captureStackTrace) {
|
|
|
|
assert.notInclude(err.stack, 'assertEqual', 'should not have internal stack trace in error message');
|
|
|
|
assert.include(err.stack, 'fooThrows', 'should have user stack trace in error message');
|
2012-06-26 16:35:41 +00:00
|
|
|
}
|
2012-02-22 18:43:44 +00:00
|
|
|
}
|
|
|
|
});
|
2012-02-23 04:45:19 +00:00
|
|
|
});
|