Open pdeszynski opened 1 year ago
I think this is an allowed scenario.
Also an issue was already closed with some PRs being added https://github.com/pact-foundation/pact-reference/issues/205 so I'm assuming that this should work already?
Assuming this fixes it, we'll need to :
v2
variant of that method@mefellows thank you for a fast answer.
Sorry, I didn't look whether it's already released 😞
Is there any suggested workaround to handle arrays right now? I've tried to use term
/ regex
on the query
field itself, but that does lead to serialize term as a json
instead of adding matching rules.
The only way that comes into my mind right now is to change tests to be parametrized and generate pacts for multiple array lengths
I don't know of a workaround just yet, but if you're up for a PR that might help shortcut a resolution?
Aside, but why are you trying to put matchers in the query parameter?
params: {
ids: ['id'], <-- this is exactly what you're sending, you don't need a matcher
},
@TimothyJones I've explicitly passed there an exact value so the contract definition would generate, I know that the test does not make sense in any way.
I'm using matchers in most of the cases to have generic endpoints in pact stub server, this way I do not have to take care of different array lengths (for e.g. to handle IDs from a DataLoader
)
I don't know of a workaround just yet, but if you're up for a PR that might help shortcut a resolution?
Yeah, I think that should be the way to go
Ah right! Interesting use case
Software versions
Please provide at least OS and version of pact-js
v19.7.0
Issue Checklist
Please confirm the following:
Expected behaviour
When running test like:
Should generate a matching rule like:
Actual behaviour
Running previous test generate pact with a rule on
$.ids[0]
and an example value for ids. This makesstub-server
not matching requests.Whether such case is not described in the docs, then using a
term
should be:Also an issue was already closed with some PRs being added https://github.com/pact-foundation/pact-reference/issues/205 so I'm assuming that this should work already?
This also leads to wrongly generated
matchingRule
($.ids[0]
instead of$ids
)Steps to reproduce
Run the snipped above / replace
MatchersV3.eachLike
withMatchers.term({generate: 'id', matcher: '(.+)'})
Relevant log files
None