-
-
Notifications
You must be signed in to change notification settings - Fork 693
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
String should appear n times in another string #971
Comments
@lithin Thanks for the post. What's the syntax that you're thinking about for this? |
Thanks for getting back to me @meeber :) I was thinking something like:
Do you think that's a good way to go about it? |
I'm not yet sure how I feel about this. Some scattered thoughts and questions to ponder:
|
Hey I totally agree with the points you raised - even when I was suggesting Probably something like I'd say that it needs to be "exactly three times" as opposed to "at least three times". If we're using I think this could work with all assertions that check that "something is there", adding "something is there exactly this many times". |
Hi, @lithin, thanks for your issue! I've thought about this for a bit of time and I'm not sure we should accept it for the following reasons:
@meeber and other contributors have discussed this in other assertions and we've faced problems with similar approaches that encourage "loose" assertions, so I'd like to avoid adding any similar features. By taking this approach I think we will be trying to "educate" users to avoid this kind of assertion. You can read more about this at #892 and I've also made a related blog post a while ago. Recently we have even added warnings in our docs to avoid using However I'd like to offer you my support if you'd like to create a plugin with a few If any other members disagree, please let me know and thanks again for your issue @lithin 😄 Edit: Just thought a bit more about this and I think it could be useful for long texts, even though we could compare them using If we decide on adding this, I thought about using the existing Please let me know what you think, I'm seriously in doubt. |
I'll add to this; that if you wanted to - you could always use the |
Thank you for the issue IMHO this looks like plugin land. As @keithamus said, it looks like |
So @lithin hopefully this gives you some good answers and some context about adding it into core. I think I'll close this issue for now. We have the chai-strings plugin, and we try to make a conscious effort to not copy what plugins have done into core. If you want to continue the discussion, please feel free to do so and we can always re-open if there is strong evidence to add into core 😄. |
I have seen myself write this assertion today and couldn't find a better way with chai. Might be worth implementing?
result.match(/BBQ Dip/g).should.have.length(3);
I'm happy to do that if you find it useful.
The text was updated successfully, but these errors were encountered: