-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
Adding descriptions to assertions? #377
Comments
(Note: apparently, you can do this with an |
Hey @tgoorden thanks for the issue! You can do this with many expect methods, but not for properties. For example: expect(something).to.not.equal(undefined, 'Foo'); My advice, if you want those messages, is to not use property assertions (like The message is a simple flag on an assertion - so we could add a method such as your |
@tgoorden what are your thoughts about my above comment? Did this solve your issue satisfactorily? |
Hmm. I just saw your comment now. We're using a mixture of asserts and expectations now. I remember this kind of "name chain element" from certain Java libraries. I think it might improve readability a little bit, but it's not crucial indeed. The |
I guess my main concern with I'd be much more inclined to accept a patch if it was a slightly less obvious method name - perhaps something like |
I'm surprised, because in nodejs, i'm used to do :
Why couldn't it be useful for your case ? |
@abenhamdine has a totally good point, and taught me something about Chai!
As such, I think I'm going to close this one. If you feel this doesn't fix your problem though @tgoorden, please reply and I can re-open, or raise a new issue. |
I know this old, but can't help adding a comment here that Specs2 (Scala) is using This is what it would look like in Chai: expect(something).aka('the thing').to.be.a('string'); |
|
|
PHPUnit utilizing |
When doing something like:
expect(something).to.exist
the output of a failure tends to be:
AssertionError: expected undefined to exist
This is not very helpful if there is trouble with the stack-trace, something you can run into e.g. when using Chai+Mocha+Velocity+Meteor.
Ideally, there'd be something like an
as(label)
to add to the expectation:expect(something).as('Foo').to.exist
which could then generate a more helpful output:
AssertionError: expected Foo to exist
The text was updated successfully, but these errors were encountered: