-
Notifications
You must be signed in to change notification settings - Fork 18
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 support for not contains json matcher #42
Comments
Here's a PR. Not sure if I did everything right, so don't hesitate to roast me. 😄 Thank you ! |
Maybe we could use Also I think we could support this for all matchers, what do you think? |
Good point! |
perfect, thanks! |
Done ! I added support for every matchers negation with: |
Hi everyone.
I created this issue instead of a PR to talk about it with you first. I'm still 100% motivated to code it myself though.
Here's the issue: Today we can't make an explicit, concise and human readable test that a JSON field doesn't contain a string.
How about adding a way to negate matchers or add new negated matchers
not contain
/not contains
? (or even!contains
)Example / Use case
Let's say I want to test this object :
Additionally
a
andb
:=> I don't want to use the
equals
matcher because I'll have to update every tests every time, plus my tests would be over verbose.Now let's pretend that I have to develop a new feature where:
foo
query param only fora
b
(i.e. they have a similar method of generation and errors could be made)I'd want to test that :
a
containsfoo
b
does not containfoo
And here's what it would look like today :
The only way to do the second test is to match the value against
^((?!foo).)*$
withmatch
, which is not really human readable and more error prone than a simplenot contains
.The negated contains would look like this:
WDYT @plouc @leguellec ?
TL;DR
Need to test if a value is not contained by another one, but regexps are not human friendly :
The text was updated successfully, but these errors were encountered: