Closed mefellows closed 5 months ago
The interaction has been misconfigured with a type matcher for the path. This is a Pact-JS issue.
matching_rules: MatchingRules { rules: {PATH: MatchingRuleCategory { name: PATH, rules: {DocPath { path_tokens: [Root], expr: "$" }: RuleList { rules: [Type], rule_logic: And, cascaded: false }} }} }
Ah, good spot! So I need to think about how this function should be defined. It's currently both a matcher and a generator - I think it should not be a matcher itself, but potentially could also accept a matcher or expression in the example
e.g. matcher
withRequest: {
method: 'GET',
path: fromProviderState('${iri}', regex(/..../, '/api/users/14f6626f-c51e-4311-ac52-182c8f2a7634'))
},
or expression
withRequest: {
method: 'GET',
path: fromProviderState('${iri}', "matching(regex, '\\xyz', '/api/users/14f6626f-c51e-4311-ac52-182c8f2a7634')")
},
Which one (if any) is the right approach here?
Pact-JVJM only sets the generator: https://github.com/search?q=repo%3Apact-foundation%2Fpact-jvm%20pathFromProviderState&type=code
ok cool, thanks. Is it true that any expression can be used in the second part, or only expressions (of another kind) that contain the dynamically replaceable values?
I don't know if that is true. It could be. It could also be false.
Via: https://github.com/pact-foundation/pact-js/issues/1088
Summary
When I add interaction like this:
I expect mock server should return
404
for this requestGET /any
, but it return200
with body{"id": "14f6626f-c51e-4311-ac52-182c8f2a7634"}
Expected behaviour
The request GET /any should return 404, and mock server should report the request GET /api/users/14f6626f-c51e-4311-ac52-182c8f2a7634 is expected but not received.
Actual behaviour
The request GET /any return 200 with json body that didn't belong to it.
Steps to reproduce
Here is the demo project https://github.com/tienvx/test-from-provider-state-generator
Relevant log files