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

Add optional message argument to all function assertions #186

Open
jakubgs opened this issue Jun 19, 2017 · 3 comments
Open

Add optional message argument to all function assertions #186

jakubgs opened this issue Jun 19, 2017 · 3 comments

Comments

@jakubgs
Copy link

jakubgs commented Jun 19, 2017

Regular function assertions in Chai have an optional msg argument, for example:

http://chaijs.com/api/bdd/#method_include

But the chai-enzyme functions do not have it. I consider adding messages at the end of the assert much more readable than in the expect() function, so most of my tests use that form. With chai-enzyme I have to mix two styles now since I cannot supply a msg to something like to.contain.text().

@keithamus
Copy link
Contributor

Going to slide in here with some questions unrelated to the issue here;

I consider adding messages at the end of the assert much more readable than in the expect() function

How do you consider adding custom messages more readable? What do you provide to the message parameter that the default messaging doesn't give you? (Asking because we'd like to improve messaging in chai, but would like feedback from users).

@jrnail23
Copy link

I'll chip in and say that a custom message argument allows you to describe why you're making an assertion. e.g.,

expect(yourElement)
 .to.contain.text('hello', 'because it would be impolite not to say hello')

@keithamus
Copy link
Contributor

keithamus commented Jul 26, 2017

@jrnail23 thanks for that, and that is indeed a fine use case. FWIW we wont be removing the message feature - and we very much encourage people to use it for use cases like the above, I was questioning because I want to ensure that without the message, Chai gives users the best clue as to what is going wrong (even if that doesnt tell them why); and so if there is anything we can do to improve the default messaging, we would like to.

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

No branches or pull requests

3 participants