Pact Matcher api has a type based matcher 'like' enter image description here
Does this matcher have something to do with the typescript type? For example, if there are types
type TestType = {
field1: string | number;
field2: TestType2
}
type TestType2 = "option1" | 'option2'
and a matcher is generated from it. Will Pact (contract) be created based on typescript type 'TestType'? or Pact will guess the type based on the value? (In this case, field1, field2 are string)
const testData:TestType = {
field1: 'stringValue',
field2 'option1'
}
const matcher = MatcherV3.like(testData)
I was expecting that field2 should accept only the literal value 'option1' and 'option2' for provider verification but it seems that using arbitrary string value is also accepted, which gives me the impression that Pact 'like' matcher is just guessing the type based on the example value but doesn't have anything to do with the typescript.
which gives me the impression that Pact 'like' matcher is just guessing the type based on the example value but doesn't have anything to do with the typescript.
This is correct, the like
matcher uses the data type, and not the TypeScript types.