-
Notifications
You must be signed in to change notification settings - Fork 8
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
Added Min and Max to pactum-matchers for int
and float
#24
base: main
Are you sure you want to change the base?
Conversation
Related PR: pactumjs/pactum#306 |
How do you ensure that a number is in a range with lt and gt? Like how would I express
|
Let me know. I would like to dive deeper into adding more complex matchers |
One way to solve is to call await spec()
.get('https://randomuser.me/api')
.expectJsonMatch({
"age": gt(0)
})
.expectJsonMatch({
"age": lt(10)
}); Other ideas would be (need dev effort)
|
@@ -212,6 +212,25 @@ function compareWithInt(actual, rule, path) { | |||
if (type !== 'number') { | |||
throw `Json doesn't have type 'number' at '${path}' but found '${type}'`; | |||
} else { | |||
if ('options' in rule && rule.options !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this new code to a common function and reuse for both int
and float
comparisons
@nergmada your changes are looking good. Could you please add some test cases. |
@nergmada are you planning to add unit tests for your changes? |
This PR adds optional non-breaking min and max criteria for ints and floats in pactum-matchers. I have that updates pactum to use this project as a PR dependency that would make debugging easier in the future.