Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expect throw test fails in Safari #116

Closed
ryandesign opened this issue Dec 1, 2012 · 3 comments
Closed

expect throw test fails in Safari #116

ryandesign opened this issue Dec 1, 2012 · 3 comments
Labels

Comments

@ryandesign
Copy link

The "expect throw" test on http://chaijs.com/api/test/ fails on Safari 6.0.2 on OS X 10.8.2 as follows:

throw
expected 'expected [Function] to not throw PoorlyConstructedError but { name: \'PoorlyConstructedError\',\n  line: 561,\n  sourceURL: \'http://chaijs.com/public/js/tests/expect.js\',\n  stack: \'ickyErrFn@http://chaijs.com/public/js/tests/expect.js:561\\nassertThrows@http://chaijs.com/chai.js:1324\\n@http://chaijs.com/chai.js:2682\\n@http://chaijs.com/public/js/tests/expect.js:627\\nerr@http://chaijs.com/api/test/:19\\n@http://chaijs.com/public/js/tests/expect.js:628\\nrun@http://chaijs.com/public/js/tests/mocha.js:3407\\nrunTest@http://chaijs.com/public/js/tests/mocha.js:3719\\n@http://chaijs.com/public/js/tests/mocha.js:3778\\nnext@http://chaijs.com/public/js/tests/mocha.js:3647\\n@http://chaijs.com/public/js/tests/mocha.js:3656\\nnext@http://chaijs.com/public/js/tests/mocha.js:3604\\n@http://chaijs.com/public/js/tests/mocha.js:3624\\n@http://chaijs.com/public/js/tests/mocha.js:4479\\n[native code]\' } was thrown' to equal 'expected [Function] to not throw PoorlyConstructedError but { name: \'PoorlyConstructedError\' } was thrown'
assert@http://chaijs.com/chai.js:241
assertEqual@http://chaijs.com/chai.js:676
@http://chaijs.com/chai.js:2682
err@http://chaijs.com/api/test/:22
@http://chaijs.com/public/js/tests/expect.js:628
run@http://chaijs.com/public/js/tests/mocha.js:3407
runTest@http://chaijs.com/public/js/tests/mocha.js:3719
@http://chaijs.com/public/js/tests/mocha.js:3778
next@http://chaijs.com/public/js/tests/mocha.js:3647
@http://chaijs.com/public/js/tests/mocha.js:3656
next@http://chaijs.com/public/js/tests/mocha.js:3604
@http://chaijs.com/public/js/tests/mocha.js:3624
@http://chaijs.com/public/js/tests/mocha.js:4479
[native code]
@ryandesign
Copy link
Author

As does the "should throw" test:

throw
expected 'expected [Function] to not throw PoorlyConstructedError but { name: \'PoorlyConstructedError\',\n  line: 496,\n  sourceURL: \'http://chaijs.com/public/js/tests/should.js\',\n  stack: \'ickyErrFn@http://chaijs.com/public/js/tests/should.js:496\\nassertThrows@http://chaijs.com/chai.js:1324\\n@http://chaijs.com/chai.js:2682\\n@http://chaijs.com/public/js/tests/should.js:572\\nerr@http://chaijs.com/api/test/:19\\n@http://chaijs.com/public/js/tests/should.js:573\\nrun@http://chaijs.com/public/js/tests/mocha.js:3407\\nrunTest@http://chaijs.com/public/js/tests/mocha.js:3719\\n@http://chaijs.com/public/js/tests/mocha.js:3778\\nnext@http://chaijs.com/public/js/tests/mocha.js:3647\\n@http://chaijs.com/public/js/tests/mocha.js:3656\\nnext@http://chaijs.com/public/js/tests/mocha.js:3604\\n@http://chaijs.com/public/js/tests/mocha.js:3624\\n@http://chaijs.com/public/js/tests/mocha.js:4479\\n[native code]\' } was thrown' to equal 'expected [Function] to not throw PoorlyConstructedError but { name: \'PoorlyConstructedError\' } was thrown'
assert@http://chaijs.com/chai.js:241
assertEqual@http://chaijs.com/chai.js:676
@http://chaijs.com/chai.js:2682
err@http://chaijs.com/api/test/:22
@http://chaijs.com/public/js/tests/should.js:573
run@http://chaijs.com/public/js/tests/mocha.js:3407
runTest@http://chaijs.com/public/js/tests/mocha.js:3719
@http://chaijs.com/public/js/tests/mocha.js:3778
next@http://chaijs.com/public/js/tests/mocha.js:3647
@http://chaijs.com/public/js/tests/mocha.js:3656
next@http://chaijs.com/public/js/tests/mocha.js:3604
@http://chaijs.com/public/js/tests/mocha.js:3624
@http://chaijs.com/public/js/tests/mocha.js:4479
[native code]

@logicalparadox
Copy link
Member

It looks like this is a result of Safari including addition properties in the error object, not of an issue with chai's throws assertion. The side effect of Safari's additional error properties (namely stack) is that when we attempt to serialize the error for display it doesn't match.

Again, this is not a blocking issue. expect().throw, assert.throws, should.throw and any other aliases will work as expected, however the error messages will be different between environments. We should investigate better serialization of error objects for display.

@logicalparadox
Copy link
Member

This has been fixed in 364939e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants