A Testing Strategy Teams Actually Adopted
Case study — raising coverage with network-level mocks instead of brittle ones, shipping features test-first, speeding up quality checks, and getting Playwright adopted across several teams.
Context
At Sky I worked across several React front ends for network automation tooling. As in most growing estates, testing maturity varied from service to service, and end-to-end testing leaned on manual checks. The team had a coverage goal and wanted tests that would actually earn their keep.
Problem
Coverage goals on their own produce bad tests. The quickest way to hit a number is to mock every module and assert on implementation details, which gives you tests that break on every refactor and catch very little. Two practical things also mattered: quality checks in CI had to be fast enough to keep feedback tight, and end-to-end tests needed a way through corporate single sign-on.
What I did
- Mocked the network, not the code. I introduced MSW handlers into the test setup, so tests exercised the real data layer against realistic API responses (Stop Mocking Fetch). Writing tests got quicker, and they survived refactors.
- Refactored services towards testability. Pure logic moved into plain functions with unit tests; hooks and pages got integration tests. This is the strategy in React Testing Strategy.
- Got a free offline mode. The same handlers ran in the browser, so the app could run locally against mocks. Demos and development stopped depending on a shared environment being up.
- Shipped new features test-first. On a new component library, the first end-user feature was written tests-first (unit, integration and stories) and became the pattern the team copied (Storybook).
- Made quality visible and fast. I optimised the lint job so it ran several times faster, and added per-line and overall coverage indicators to every merge request, so reviewers could see untested lines immediately.
- Used AI to fill the gaps, in a contained way. This was my first use of AI on a team. We wrote about 70% of the unit and integration tests by hand, so the assistant had good patterns to copy, then let it generate much of the rest, always reviewed. We applied it with the boy scout rule: whenever we touched a service below the 90% coverage target, AI filled the gap for that service. Clear API contracts are what made the generated tests trustworthy. Today I’d go a step further and close the loop: when a contract changes, regenerate the mocks and rerun the consumers’ tests automatically.
- Championed Playwright across departments. I worked through the authentication problem (test users and test-friendly auth policies in non-production environments), and set up mocked-state suites that ran in pipelines and doubled as stable environments for demos and user acceptance testing (Playwright).
Outcome
Coverage on the services I focused on rose substantially, with tests that were meaningful rather than brittle. Playwright was adopted for end-to-end testing across departments, as the CV says, and AI tooling helped extend unit-test coverage across projects. Feedback in merge requests got faster and more informative.
What I’d do again
- Pick the mocking boundary first. Everything else follows from mocking at the network.
- Make the right thing visible. Coverage shown in every merge request changed behaviour more than any coverage target did.
- Solve the boring blocker. For end-to-end tests the blocker wasn’t the framework, it was authentication. Fixing that unlocked everything.
What I’d do differently
Add contract checks earlier. Mocks drift from the real API, and a few consumer-driven contract tests would have caught mismatches before integration did.
Related notes
Shift Left Testing · Removing Secrets from Git History · Building a Graph Component Library
- #testing
- #msw
- #playwright
- #ci
- #coverage
- #case-study
↩ Linked from (10)
…elopment aid, not a loop running ahead of us. The confidence that bought is what made the next rung possible (A Testing Strategy Teams Actually Adopted).
…ipt errors to zero (Driving a TypeScript Codebase to Zero Errors), a coverage drive with network-level mocks (A Testing Strategy Teams Actually Adopted), secret scanning, and an API gateway in front of the services (Roll…
Communicating with Stakeholders · A Testing Strategy Teams Actually Adopted · Design Review Readiness Checklist
Pair Programming · Communicating with Stakeholders · A Testing Strategy Teams Actually Adopted · Headless Component Libraries
Fast Feedback from Deploy Previews · A Testing Strategy Teams Actually Adopted · Slicing Pull Requests · Playwright
…ng test coverage on every merge request made a real difference to how a team I worked with used its pipeline (A Testing Strategy Teams Actually Adopted). It's Shift Left Testing applied to the pipeline itself.
- PlaywrightGrowing
…: Train for the Production You Actually Run). Where it fits in the bigger picture: React Testing Strategy and A Testing Strategy Teams Actually Adopted.
- React Testing StrategyEvergreen
…took a team from patchy coverage to high, meaningful coverage on several services without brittle mocks — see A Testing Strategy Teams Actually Adopted. The broader principle of catching problems early and cheaply is Shi…
- Stop Mocking FetchEvergreen
…k-level mocks made them quicker to write and noticeably more stable through refactors. It was the backbone of A Testing Strategy Teams Actually Adopted and sits at the centre of my React Testing Strategy.
…heorise. Five minutes beside the person hitting the bug beat a day of guessing. It's the same instinct behind A Testing Strategy Teams Actually Adopted: get close to how the software is really used. Value the people who…
↪ Links to (8)
Related by topic
- Seed
Make the System Explain Itself
Platform engineering - Seedcase study
Making Room for Career-Changers
Career - Seed
Prototype or Product? Scoping a Request Honestly
Career - Growingcase study
Smart TV Apps on Low-End Devices
Frontend craft