<#1076 `MatchersV3.date` and `MatchersV3.time` do ...
# pact-js-development
g
#1076 `MatchersV3.date` and `MatchersV3.time` do not use example value on the provider side Issue created by agross Software versions • OS: macOS 13.2.1 • Consumer Pact library: Pact JS 11.0.2 • Provider Pact library: PactNet 4.4.0 • Node Version:
v16.19.0
Issue Checklist Please confirm the following: ☑︎ I have upgraded to the latest ☑︎ I have the read the FAQs in the Readme ☑︎ I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures ☑︎ I have set my log level to debug and attached a log file showing the complete request/response cycle ☐ For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem Expected behaviour We use
MatchersV3.date
and
MatchersV3.time
. The docs state:
String value that must match the provided date/time format string. [...] If the example value is omitted, a value will be generated using a Date/Time generator and the current system date/time.
The expected behavior is that the provider will receive the passed example value of `101112`:
Copy code
const x = MatchersV3.time("HH:mm:ss", "10:11:12")
Actual behaviour The provider receives a generated date/time value, despite examples being given. The Pact JSON file also contains
generators
for such date or time matchers. Seems to be related to #620 which fixed it for
MatchersV3.datetime
. While researching this I came across this document which seems to indicate that date/time values on the provider side could be dynamically generated. How can such expressions be included when generated values are used (i.e. no concrete examples are given, but a recipe describing the values to be generated). It would be very useful to use because "the current date/time" is not enough for most of our use-cases. Steps to reproduce
Copy code
const d = Matchers.date("yyyy-MM-dd", "2023-02-01");
expect(d["pact:generator:type"]).toBeUndefined();

const t = Matchers.time("HH:mm:ss", "10:11:12");
expect(t["pact:generator:type"]).toBeUndefined();
pact-foundation/pact-js