How do you test, monitor and roll back independently deployed micro-frontends?
AdvancedMicro-frontends interview questionBy UIRound, updated 21 November 2026
Short answer
Test each micro-frontend in isolation, then test the promises between them with contract tests that run in both the host's and each remote's pipeline, plus a short smoke test of the composed app before release. Tag every error and performance metric with the remote's name and build id so alerts reach the owning team. Load remotes through a versioned manifest or import map, so rolling back is one edit with no rebuild.
Why the usual test pyramid is not enough
Unit and component tests still do most of the work inside each app; unit vs integration vs end-to-end tests covers that split. What they cannot catch is the failure specific to micro-frontends: two apps that each pass their own tests but no longer fit together. A remote renames an exposed module, the host passes a prop the remote stopped reading, or a remote starts requiring a newer React than the host shares. Nothing fails until a user loads the page, so the extra layer is about the seams: contracts, composition and attribution.
Contract tests between host and remotes
A contract is the list of promises one side makes to the other:
- which modules a remote exposes and what each exports (a mount function, a component)
- the props or mount context each one accepts
- the events it emits and listens for, with their payload shapes
- the shared dependency ranges it can run with
Write the contract down as types and a small schema in a package both sides depend on, then test it from both directions.
In the remote's pipeline, load the built remote the way the host would and check that it keeps its side:
// cart/contract.test.ts, run against the production build output
import { loadBuiltRemote } from "./test-utils";
test("exposes ./CartWidget with a mount function", async () => {
const mod = await loadBuiltRemote("./CartWidget");
expect(typeof mod.mount).toBe("function");
});
test("mounts with the host's minimal context and unmounts cleanly", async () => {
const { mount } = await loadBuiltRemote("./CartWidget");
const el = document.createElement("div");
const unmount = mount(el, minimalHostContext());
expect(el.childElementCount).toBeGreaterThan(0);
unmount();
expect(el.childElementCount).toBe(0);
});In the host's pipeline, run the host against the current production version of every remote, so a host change that breaks a live remote fails before it ships.
Event payloads are where drift hides longest. Checking each consumer's recorded fixtures against the producer's schema is the same technique as catching API contract drift, applied to events between apps.
A composed smoke test before promotion
Contracts check shapes, not behaviour. Before a new remote build becomes live, run a short end-to-end suite against the real host with a manifest that points at the candidate build. Keep it to the few journeys that must never break: the page loads, the user can sign in, the main action in each area works. Most teams use a preview override (a cookie or query parameter that swaps one manifest entry) so the test runs inside the production shell without affecting real users. Reliable end-to-end tests with Playwright covers keeping such a suite stable.
Monitoring per remote
When ten builds from five teams run on one page, an alert that says "JavaScript errors are up" is useless. Every signal needs to say which app and which build produced it.
- Tag errors with app and build id. The host can set the context when it mounts each remote, and each remote should upload source maps for its own build so stack traces resolve. See what source maps are for.
- Group errors across deploys. Stack frames change with each build, so group by a normalised fingerprint, as in grouping frontend errors by fingerprint.
- Track load failures separately. A failed remote entry or chunk request usually means a bad deploy, a deleted build or a wrong cache header, not a code bug. Count them per remote.
- Measure performance per area. Report Web Vitals with the active app as a dimension, and time how long each remote takes from navigation to mount. Building a performance monitor shows the browser side.
- Route alerts to owners. The app tag decides which team gets paged.
Compare the new build's error rate and load failures against the previous build during a canary. That comparison is the signal for whether to widen the rollout or roll back.
Versioned manifests and import maps for instant rollback
Rollback is fast only if the host never hard-codes where a remote lives. Each build goes to its own immutable path, and a small, briefly cached manifest says which one is live:
{
"cart": { "entry": "https://cdn.example.com/cart/b7f3a21/remoteEntry.js", "previous": "https://cdn.example.com/cart/9c01e4d/remoteEntry.js" },
"search": { "entry": "https://cdn.example.com/search/41d8aa0/remoteEntry.js" }
}With import maps the same idea is a map from names to versioned URLs, generated per release:
<script type="importmap">
{ "imports": { "@shop/cart": "https://cdn.example.com/cart/b7f3a21/cart.js" } }
</script>Rolling back means writing the previous URL into that entry. There is no rebuild, the change reaches users on their next page load, and the owning team can do it without touching any other app. Keep every manifest version in history so you can see what was live at any moment, and keep old builds on the CDN so open tabs can still load their chunks. The full deploy setup, including cache headers, is in deploying and versioning micro-frontends independently. To see how browsers resolve those names, try resolving specifiers with an import map.
Common follow-up questions
Do contract tests replace end-to-end tests?
No. Contract tests are fast and catch shape changes on every commit. A small end-to-end suite catches behaviour that only appears when the apps run together. You need both, with far more contract tests than end-to-end ones.
What if a rollback needs the host to change too?
Then the contract was broken. Keep host changes backward compatible, so the host supports both the old and new remote until the new one has been stable for a while.
What about a shared dependency upgrade that breaks things?
Roll back the remote that introduced it. If several apps upgraded together, roll them back together, which is why upgrades to shared singletons should be coordinated releases.
Mistakes to avoid
Testing each app only in isolation and finding integration breaks in production
Errors and metrics without an app name and build id
Rolling back by rebuilding and redeploying instead of editing the manifest
Deleting old builds as soon as a new one is live
Caching the manifest or an unversioned entry file for a long time, so rollbacks do not reach users
Practise it in code
Interviewers rarely stop at the definition. These questions open in an editor with tests.
- Catch API contract drift by checking consumer fixtures against the provider schemaMedium35 min
- Group frontend errors by fingerprint: normalise stack frames across deploys, then count and sample each groupMedium40 min
- Design one build promoted across environments: runtime config, secrets, previews and rollbackHard45 min
- Resolve module specifiers with an import map:
imports, trailing-slash prefixes and the most specificscopesHard50 min - Implement a performance monitor measuring Web Vitals and reporting metricsMedium45 min
- Design a micro-frontend shell with independent deployment and shared dependency versioningHard60 minFree