chai/test/configuration.js

46 lines
1.5 KiB
JavaScript
Raw Normal View History

describe('configuration', function () {
2012-11-29 08:18:48 +00:00
var assert = chai.assert;
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
}
it('Assertion.includeStack is true', function () {
var orig = chai.Assertion.includeStack;
chai.Assertion.includeStack = true;
try {
fooThrows();
assert.ok(false, 'should not get here because error thrown');
} catch (err) {
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');
}
}
});
it('Assertion.includeStack is false', function () {
var orig = chai.Assertion.includeStack;
chai.Assertion.includeStack = false;
try {
fooThrows();
assert.ok(false, 'should not get here because error thrown');
} catch (err) {
chai.Assertion.includeStack = orig;
// 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-02-23 04:45:19 +00:00
});