Hello! I wanted to know is pact contract testing u...
# pact-js
n
Hello! I wanted to know is pact contract testing useful for microfrontends? Is it common to use it for that case? I know it is possible but im asking if its useful/common.
m
I’ve heard people asking, but it’s still theoretical to me. Interested in the discussion…
b
I don't see how a micro-front-end is different to any other front-end, from this testing perspective 👍 I've used it across both gaps in a MFE->BFF->API scenario (to great effect).
It might depend on your MFE architecture, though? For example, if you have UIs mounted into a backing container that centralises API clients, then the MFE bit is probably irrelevant. But if each MFE has it own API clients, then they're like any other front-end. I think my conclusion is, it's irrelevant either way. But maybe there's some combo I haven't though of.
n
I see, well we are still working on the architecture of our MFE as we are in the process of moving from a monorepo to microfrontends. But the idea is to have each page in a seperate repo so that we can deploy them separately. We are trying to eliminate most if not all cypress e2e tests so we don't want to keep having to spin up all of our services to run e2e tests. That was when the conversation of contract testing came up as we were worried if we removed or minimized the e2e tests we might need some more assurance integrations are working together.
b
I did a whole talk about the balance of different kinds of tests 😅 It's a good idea to have a light run of e2e tests for connectivity checking after deploy (and ideally before real traffic is routed), but you shouldn't need heaps of e2e coverage. Best use case for Cypress is to stubbed API clients, so you don't have to do network hops & can simulate all response cases (without having to seed data in external sources, work out how to orchestrate weird cases, or keep all of those fixtures in sync). Pact might even be able to help you with stubbing API clients.
m
It was a good talk too ^^ 😛
😅 1
n
Hahha ill give it a watch then! Thanks
party parrot 1
l
Hey - I was just about to ask about microfrontends X pact. Admittedly, microfrontends is a completely new term for me. and for context, I'm an EM on a Developer Experience group and one of our tech leads who heads up our frontend architecture team is looking into possible solutions for testing interactions between Frontend modules.
1. Prescribing a natural way to integrate Contract Tests with FE modules (Imagine: To sub to a channel, you declare your disposition as a provider or consumer, e.g.)
Again, I'm not too privy to microfrontends and my only experience with pact is just with testing interactions between services in a monorepo...but I'd imagine that Pact is pretty agnostic of the whether or not something is a frontend; so long as it's a contract between 2 independent services?
💯 1
m
Exactly. I couldn’t tell you implementation wise, but the principle is the same
1