chai/test/configuration.js
Jake Luer a8f94bdcbb test: [karma] use karma phantomjs runner
- tests refactored as bdd instead of tdd
- removed test/browser bootstraps
- add karma-runner
2013-09-17 17:22:36 -04:00

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');
}
}
});
});