pact-foundation / pact-js

JS version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
https://pact.io
Other
1.63k stars 348 forks source link

Allow term matcher to generate integers #521

Closed callumbooth closed 2 years ago

callumbooth commented 4 years ago

Issue Classification

Bug Report

Might be related to #435 but currently it's not possible to use the term matcher with integers.

Software versions

NOTE: only applicable for bug reports

Issue Checklist

Confirm the following:

Expected behaviour

I should be able to use term() to generate integer values. Passing term({generate: '0', matcher: '0|1'}) is not suitable because the contract json file it generates will check against a string type rather than the integer type.

Actual behaviour

When passing term({generate: 0, matcher: '0|1'}) you get the message Error ocurred in mock service: RuntimeError - Value to generate \\\"0\\\" does not match regular expression....

mefellows commented 4 years ago

Thanks, should the title be "Allow term matcher to generate integers" (on "non strings"?)

Yes, at the current time, you cannot generate non-string values for a regex.

Our next major release of Pact (https://github.com/pact-foundation/pact-js#pact-js-v3) would let you do this if you wanted to try it?

callumbooth commented 4 years ago

yes, the title should be integers. I'll take a look at v3 and get back to you.

mefellows commented 2 years ago

10.x.x supports this.