You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I love testing an API and checking that the returned object is matching something. This allows me to check that some properties have the right type or values.
But when the API is returning an array of objects, and I want to check that exactly one object in the array is matching, then I don't know what to do.
Describe the solution you'd like
Suppose I have an API to create people, and list people. Each person has a nickname, and it has to be unique. I create a new person, and want to check it shows up only once in the list of people. The API has a response like this:
Describe alternatives you've considered
I considered putting the matcher in an array, but then it expects an array with a length of 1.
AssertionError [ERR_ASSERTION]: Json doesn't have 'array' with length '1' at '$' but found 'array' with length '165'
I also looked at json-query which would allow me to do that, by using the path. But then I would ideally like to create local functions (helpers) and as of now it is not possible through pactum since the json is sent as it is.
Additional context
Nothing else.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I love testing an API and checking that the returned object is matching something. This allows me to check that some properties have the right type or values.
But when the API is returning an array of objects, and I want to check that exactly one object in the array is matching, then I don't know what to do.
Describe the solution you'd like
Suppose I have an API to create people, and list people. Each person has a nickname, and it has to be unique. I create a new person, and want to check it shows up only once in the list of people. The API has a response like this:
I would like to be able to test it with:
Or:
Describe alternatives you've considered
I considered putting the matcher in an array, but then it expects an array with a length of 1.
I also looked at json-query which would allow me to do that, by using the path. But then I would ideally like to create local functions (helpers) and as of now it is not possible through pactum since the json is sent as it is.
Additional context
Nothing else.
The text was updated successfully, but these errors were encountered: