Dor Meiri
07/15/2022, 12:59 PMDor Meiri
07/17/2022, 4:24 PMBoris
07/18/2022, 12:28 AMBoris
07/18/2022, 12:29 AMTimothy Jones
07/18/2022, 12:49 AMTimothy Jones
07/18/2022, 12:50 AMTimothy Jones
07/18/2022, 12:50 AMTimothy Jones
07/18/2022, 12:50 AMTimothy Jones
07/18/2022, 12:51 AMTimothy Jones
07/18/2022, 12:52 AMTimothy Jones
07/18/2022, 12:52 AMBoris
07/18/2022, 12:54 AMTimothy Jones
07/18/2022, 12:58 AMTimothy Jones
07/18/2022, 12:59 AMTimothy Jones
07/18/2022, 1:00 AMTimothy Jones
07/18/2022, 1:01 AMTimothy Jones
07/18/2022, 1:02 AMTimothy Jones
07/18/2022, 1:04 AMTimothy Jones
07/18/2022, 1:04 AMTimothy Jones
07/18/2022, 1:06 AMgetOrder(id: string): Promise<Order>;
work correctly and return what you expect.Timothy Jones
07/18/2022, 1:07 AMgetOrder
Timothy Jones
07/18/2022, 1:07 AMgetOrder
Timothy Jones
07/18/2022, 1:09 AMgetOrder
Dor Meiri
07/18/2022, 6:55 AMTimothy Jones
07/18/2022, 6:56 AMTimothy Jones
07/18/2022, 6:56 AM{
"firstName": "Dor"
}
Timothy Jones
07/18/2022, 6:57 AMTimothy Jones
07/18/2022, 6:57 AM{
"firstName": like("Dor")
}
Timothy Jones
07/18/2022, 6:58 AM{"firstName": "Tim"}
)Dor Meiri
07/18/2022, 6:59 AMlike(mock.getOrder)
it will have similar result?
It doesnt give us flexibility of using the matcherDor Meiri
07/18/2022, 7:00 AMBoris
07/19/2022, 12:31 AMBoris
07/19/2022, 12:33 AMlike(mock.getOrder)
will probably get you close to schema-level flexibility & reasoning. It doesn't let you specify which parts of the payload are important in value vs shape/type.Timothy Jones
07/19/2022, 2:17 AMlike(wholePayload)
is that you will only match on the json types of everything.
If your payloads are simple then you can totally get away with it. However, it won't work for all payloads, so you might miss things:
Cases where this won't work include:
⢠where the client only understands specific values where you need an enum (say userType
which could be "admin"
or "member"
- this is an important part of the contract, because you want to be sure that the backend doesn't return "someOtherType"
or maybe "ADMIN" if your client is case sensitive) .
⢠If you have any arrays, it will tie the backend to providing exactly that structure
⢠Same thing you have any objects used as mapsDor Meiri
07/19/2022, 9:42 AMmock.getOrder(id)
and translate it to a Pact response body more precisely according to the test, something like this:
const order = mock.getOrder(id);
const expectedResponseBody: Order = {
id,
name: like(order.name),
// ...
}
So my pact tests can use my mocks, with the flexibility of using matchers.
Right now, this seems the easiest way to manage the mocks in our services.
WDYT?Timothy Jones
07/19/2022, 11:24 AMTimothy Jones
07/19/2022, 11:25 AMTimothy Jones
07/19/2022, 11:25 AMDor Meiri
07/19/2022, 11:26 AM