2012-02-22 18:43:44 +00:00
|
|
|
if (!chai) {
|
|
|
|
var chai = require('..');
|
|
|
|
}
|
|
|
|
|
|
|
|
var assert = chai.assert;
|
|
|
|
|
2012-02-24 23:24:48 +00:00
|
|
|
function fooThrows () {
|
|
|
|
assert.equal('foo', 'bar');
|
|
|
|
}
|
2012-02-22 18:43:44 +00:00
|
|
|
|
2012-02-24 23:24:48 +00:00
|
|
|
suite('configuration', function () {
|
2012-02-23 04:45:19 +00:00
|
|
|
|
2012-02-22 18:43:44 +00:00
|
|
|
test('Assertion.includeStack is true, stack trace available', function () {
|
|
|
|
chai.Assertion.includeStack = true;
|
|
|
|
try {
|
|
|
|
fooThrows();
|
|
|
|
assert.ok(false, 'should not get here because error thrown');
|
|
|
|
} catch (err) {
|
2012-02-22 22:45:42 +00:00
|
|
|
if (typeof(err.stack) !== 'undefined') { // not all browsers support err.stack
|
2012-02-23 04:45:19 +00:00
|
|
|
assert.include(err.stack, 'at fooThrows', 'should have stack trace in error message');
|
2012-02-22 22:45:42 +00:00
|
|
|
}
|
2012-02-22 18:43:44 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Assertion.includeStack is false, stack trace not available', function () {
|
|
|
|
chai.Assertion.includeStack = false;
|
|
|
|
try {
|
|
|
|
fooThrows();
|
|
|
|
assert.ok(false, 'should not get here because error thrown');
|
|
|
|
} catch (err) {
|
2012-02-22 22:45:42 +00:00
|
|
|
assert.ok(!err.stack || err.stack.indexOf('at fooThrows') === -1, 'should not have stack trace in error message');
|
2012-02-22 18:43:44 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-02-23 04:45:19 +00:00
|
|
|
});
|