Hello, I'm hoping someone can help me understand h...
# general
c
Hello, I'm hoping someone can help me understand how the idea of a "shared fixtures" solution can work when talking about supporting both UI tests and pact consumer tests. So, my understanding is that the pact consumer tests should ideally be written in such a way that they have tight or exact request matching and loose response matching. I guess my question is: should the matching rules be defined as part of the fixture, and the non-Pact stub server needs to be able to interpret and understand those matching rules; or should the fixtures be simple request and response bodies, and we somehow with pact layer matching rules on top of those simple fixtures? The only examples I've found for using fixtures to seed pact consumer tests either don't clearly show how the fixtures are being used for UI testing (if they are at all) or use static fixtures without any matching rules. Does anyone know of any good examples of how this can work (preferably in either js or jvm, but I can work with other languages 🙏)?
I may also just be completely misunderstanding what "fixtures" are. Is it still a "fixture" if it's generated? Is the pact document a "fixture" if it is used to seed a stub server for the UI tests? Or do fixtures have to be statically defined, and if so, how can you define matching rules that apply to a static fixture?
t
The matchers are a convenience only. You’re saying to the provider team “hey, this test covers all cases where the data looks like X”- which means they don’t have to have the exact same test data you use
There’s no testing benefit from using them, it just makes it easier for provider teams to implement/ match your tests
Fixtures in this context are just a way of sharing the data you used in your pact test with the code that uses the api boundary (probably mocked). Think of it like this: Your pact test asserts that GetUser(foo) returns UserFoo Now, you can mock GetUser(foo) to return UserFoo
A matching rule would not make sense in that context, so the shared fixtures are usually just the real concrete object
There are no examples using (say) UI tests, because Pact isn’t a UI testing framework