json
07/20/2022, 7:41 PMid: "ce118b6e-d8e1-11e7-9296-cec278b6b50a"
to
id: Matchers.uuid("ce118b6e-d8e1-11e7-9296-cec278b6b50a")
I am now getting:
Object {
- "id": Object {
- "data": Object {
- "generate": "ce118b6e-d8e1-11e7-9296-cec278b6b50a",
- "matcher": Object {
- "json_class": "Regexp",
- "o": 0,
- "s": "^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$",
- },
- },
- "getValue": [Function getValue],
- "json_class": "Pact::Term",
- },
+ "id": "ce118b6e-d8e1-11e7-9296-cec278b6b50a",
}
> 92 | expect(response).toEqual(responseData)
| ^
This is all inside a pactWith
block, because this is using the jest-pact library.json
07/20/2022, 8:01 PMjson
07/20/2022, 8:20 PMMatt (pactflow.io / pact-js / pact-go)
Timothy Jones
07/20/2022, 11:14 PMI bet I can't use the matcher in my expected response, huh?This is where you're supposed to use them
Timothy Jones
07/20/2022, 11:16 PMexpect
call, and you're not supposed to do thatTimothy Jones
07/20/2022, 11:16 PMexpect
to verify that the object you got out of the API call is correct - so it won't have matchersTimothy Jones
07/20/2022, 11:18 PMresponseData
object has the matchers, you can remove them with extractPayload(responseData)
- so you would do:
expect(response).toEqual(extractPayload(responseData))
json
07/21/2022, 12:58 PMtoEqual
expectation. Making separate objects for the two of them fixed it.
I didn't know about extractPayload
though, that's a really handy tip! Thank youjson
07/21/2022, 1:25 PMextractPayload
documented anywhere?