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

oneOf matcher does not work for property with data types string | empty (“”) | null #272

Open
ASaiAnudeep opened this issue Mar 30, 2023 Discussed in #267 · 1 comment
Labels
enhancement New feature or request

Comments

@ASaiAnudeep
Copy link
Member

Discussed in #267

Originally posted by asub927 March 23, 2023
I need to validate an api which has a response property which returns string or empty or null values based on the data in the backend.

  • Initially tried with string() matcher which fails when the property value returns empty or null
  • then tried oneOf() matcher which also fails when the property value returns string()
  • works when I use any() but I want to match specific to the allowed data types

Code sample for reference. Any help to handle this condition is greatly appreciated.

_spec
.get(/api)
.expectStatus(200)
.expectJsonMatch({
property: oneOf([string(), "", null])}

@wine-fall
Copy link
Contributor

hi @ASaiAnudeep :

I don't know u have done this job or not. Anyway I just handle this issue and create a pr for pactum-matchers and another for pactum.

please review them.😁

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

No branches or pull requests

2 participants