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

Pact verify matchingRules utility #1240

Open
yoniaiz opened this issue Oct 4, 2024 · 0 comments
Open

Pact verify matchingRules utility #1240

yoniaiz opened this issue Oct 4, 2024 · 0 comments
Labels
enhancement Indicates new feature requests triage This issue is yet to be triaged by a maintainer

Comments

@yoniaiz
Copy link

yoniaiz commented Oct 4, 2024

Checklist

Before making a feature request, I have:

Feature description

Maybe i missed it so sorry about that, but is a utility that can be exported from the library to verify the match between given object and a matchingRules?

I'm trying to develop mock network request functionality for playwright tests based on existing generated pact contracts.

Building the routes from the pact JSON files is straightforward, but there is a problem when I have the same path and the same method but different responses.

For example, my contact is UsersConsumer - UsersProvider. The interactions are
GET /users -> response 200 with body { users: [] }
GET /users?limit=10 -> response 200 with body { users: [] }
GET /users -> response 401 with body { users: [] }
GET /users -> response 500 with body { users: [] }

So, to generically decide what my result is based on the request from the playwright, I need to pass the request.body, request.headers, and request.query and matchingRules to a utility to decide if they are matching
isMatch(request, interactions.request.matchingRules) => boolean something like that.

Use case

This will help create generic mock servers with any framework or tool.
It can be reused for intercepting calls in Playwright or building custom routes in MSW.

@yoniaiz yoniaiz added enhancement Indicates new feature requests triage This issue is yet to be triaged by a maintainer labels Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests triage This issue is yet to be triaged by a maintainer
Projects
None yet
Development

No branches or pull requests

1 participant