mirror of
https://github.com/chaijs/chai
synced 2024-11-15 00:07:11 +00:00
a8f94bdcbb
- tests refactored as bdd instead of tdd - removed test/browser bootstraps - add karma-runner
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
describe('configuration', function () {
|
|
var assert = chai.assert;
|
|
|
|
function fooThrows () {
|
|
assert.equal('foo', 'bar');
|
|
}
|
|
|
|
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) {
|
|
assert.include(err.stack, 'fooThrows', 'should have 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.
|
|
if ('undefined' !== typeof Error.captureStackTrace) {
|
|
assert.ok(!err.stack || err.stack.indexOf('at fooThrows') === -1, 'should not have stack trace in error message');
|
|
}
|
|
}
|
|
});
|
|
});
|