Shawn Erquhart
01/27/2023, 7:08 PMTimothy Jones
01/28/2023, 1:15 AMTimothy Jones
01/28/2023, 1:16 AMDoesn’t generating pact files from UI test interactions violate Pact’s warnings against writing contracts based on UI test cases?Yes, try not to do this
Timothy Jones
01/28/2023, 1:18 AMTimothy Jones
01/28/2023, 1:19 AMTimothy Jones
01/28/2023, 2:26 AMgenerated test cases to either be too exact or too loose.A subtlety that you might not have thought of is that the generic matchers aren’t for describing the schema, they’re for making it easier to write tests. They’re a convenience, so you don’t have to have the same exact test data on both sides. If you say
{ name: like("Steve")}
, you’re saying “this particular test case covers all possible responses where the name field is a string”Timothy Jones
01/28/2023, 2:28 AMTimothy Jones
01/28/2023, 2:29 AMTimothy Jones
01/28/2023, 2:29 AMShawn Erquhart
01/30/2023, 1:23 PM"Steve"
and Matchers.like("Steve")
produce identical output in the pact file, wow. Good point on the role of matchers, that is indeed subtle. One of the biggest challenges for contract testing is the paradigm shift, I'm still wrapping my head around that.
So maybe using the adapter is a fine approach, and it's up to us to target tests specifically against the API layer. The thing that stands out to me, though, is the experience based feedback from Pact folks is that using UI tests with Pact should be avoided because the written tests are brittle and maintaining them is overly cumbersome while providing limited value. The adapter arguably changes this - we're not writing tests, pact files are just generated based on the tests, so they may maintain themselves to an extent. I still don't have a lot of real world experience with Pact yet, so wanted to see if this rang true at all for folks who do.Timothy Jones
01/30/2023, 1:58 PMbut it’s official from PactFrom Pactflow. A different thing
Timothy Jones
01/30/2023, 1:59 PMTimothy Jones
01/30/2023, 1:59 PMTimothy Jones
01/30/2023, 2:01 PMThe adapter arguably changes this - we’re not writing tests, pact files are just generated based on the tests, so they may maintain themselves to an extent.Hmmm… At first glance, I would say that it feels like it would have the same drawbacks long term, but be much faster to get going. Provider states would be the hard part
Timothy Jones
01/30/2023, 2:02 PMTimothy Jones
01/30/2023, 2:05 PMand it’s up to us to target tests specifically against the API layerYou’re 100% right about this. This, I think, is the main part of your question - if, in your situation, it’s possible to write UI tests that target the API layer, then you’ll be ok. If not (as is usually the case, at least long term), then you might be in for a bad time
Matt (pactflow.io / pact-js / pact-go)