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.
$ cd ./topics/testing-quality
Testing strategies teams actually adopt, mocking at the network, end-to-end confidence, shifting left, and the security habits that belong in the same pipeline.
31 notes🌱 15 seed🌿 12 growing🌳 4 evergreen
Quality is a feedback loop, not a phase. These notes cover how I test front ends (at the network boundary, test-first where it pays, end-to-end where it matters), how to shift those checks left into the pipeline, and the security hygiene that belongs alongside them.
hover to explore · click to open
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.
Case study — a second-screen sign-in on a TV app, caught in testing when it failed for one careful tester. Watching them use it showed a timeout designed for fast developers, not real users. Lessons on questioning requirements out loud, testing like real users, and valuing the people who find the odd cases.
Case study — tightening the commit-to-green-tick loop: restructuring pipelines and making long jobs resumable from checkpoints cut feedback time by roughly 5×.
Intercept HTTP at the network layer so tests, Storybook and local development all hit realistic mocked APIs while your real fetching and parsing code runs.
React escapes what you put in JSX, so most XSS comes through the escape hatches — dangerouslySetInnerHTML, direct DOM writes, javascript URLs and third-party scripts. Defend in layers.
Put logic in plain functions and unit-test them; test hooks and pages as integration tests against a mocked network; assert only on what users can observe.
Mocking fetch or your own API modules couples tests to implementation and quietly re-implements your backend in every test file. Mock the network boundary instead.
AI's best use on a codebase isn't only shipping features faster. It's structure: modules, less duplication, reusable functions and, above all, explicit interfaces so nobody has to work things out at runtime. Pin shape, behaviour and users' mental models with tests so you can change safely, then change the mental model on purpose, with a learning curve that's guided and obvious.
Six months apart, the last two Thoughtworks Radars tell one story. Vol. 33 wired agents into everything through MCP; Vol. 34 asks for the fundamentals back, with harnesses, zero trust and honest metrics, because AI is generating code faster than teams can understand it.
A CVE tells you which vulnerability, CVSS tells you how bad it is in general; only your context tells you how bad it is for you. Prioritise on that, and automate upgrades with guardrails rather than blind auto-merge.
Most delivery problems start as requirements problems: a front end and a back end each building from their own reading of the same ticket. Statements of work, shared contracts, a definition of ready and a definition of done close that gap, and in the age of AI, ticket complexity is about uncertainty and verification, not typing.
Layer an agent's defences, start with PII, safety and irreversible actions, and choose deliberately where the human sits: in the loop, on the loop or above it.
When agents write most of the code, nobody can read every line with the same care. Match review depth to blast radius: deep-read infrastructure, carefully read shared code, proof-read isolated leaf code. Earn the right to read less with feature gates and proof in every PR, and remember that merge-ready isn't launch-ready.
Find defects where they're cheapest to fix, in refinement, the editor and the pull request. But shift-left means early feedback, not running every expensive test at the earliest stage.
What 'finished' means for every ticket: acceptance criteria demonstrated, tests passing in CI, contracts respected, reviewed in small PRs, observable in production, nothing left for 'someone'. AI-written code meets exactly the same bar. Best when the pipeline enforces it rather than memory.
A ticket is ready when the conversation has already happened, before the sprint, while it was still cheap: the why, examples of acceptance criteria, an agreed contract, a design, known dependencies, a small size and no unestimated unknowns. The same list is what makes a ticket usable by a coding agent.
Merge-ready code is the first ugly rep: it happened, but it isn't a skill yet. Launch-ready is owning it: repeatable, joint-safe, building what you were actually after, and linking into a flow. That last 20 % takes as long as everything before it, in training and in software.
AI coding tools pull in more packages, tools and plugins than ever, and attackers can now generate convincing malicious ones at scale. What's already happening (slopsquatting, poisoned tools, hijacked projects) and a layered defence: control what gets in, put guardrails on agents, limit the blast radius, and make it executable.
A checklist for whether a user story is ready to build: Independent, Negotiable, Valuable, Estimable, Small, Testable (Bill Wake, 2003). The questions I actually ask for each letter, and how to split a story that fails 'Small'.
End-to-end tests in real browsers with accessible locators, auth handled once via saved storage state, network control for deterministic runs, and traces that make CI failures debuggable.
Automated checks that fail the build when the architecture drifts, like a service importing a database driver directly. Cheap feedback that keeps a codebase on the shape it was designed for.
Why I moved my SSH private keys out of ~/.ssh and into a password manager's SSH agent, now that AI agents run as me on my machines. Setup, the confusing errors I hit on the way, agent forwarding from laptop and phone, and the server-side basics.
An agent that only reads HTML never sees the final render. Multimodal web agents like WebVoyager read screenshots like a person does, which unlocks real browsing and introduces the grounding problem.
Split failures into render errors, caught by error boundaries with a fallback, and network errors, caught with try/catch and retry. Make sure both paths end in a logged error and a usable screen.
My 2022 post on deployment hooks argued for building every pull request on real infrastructure, but failing fast. What I'd add: preview environments, a quick PR tier and a thorough merge tier, and releases you can flip back.
A regression with no obvious cause and hundreds of commits to search: git bisect halves the range each step, and with a test script it can find the culprit on its own.
In 2020 I sold TypeScript as documentation you get for free. Since then I've migrated a large codebase to zero type errors. Types are a contract between people as much as between functions, but only if the build enforces them.
The author of Clean Code now argues humans shouldn't review AI-written code line by line: specify what correct means, verify it with deterministic tools, and keep humans accountable for specs and sign-off.
Scan for leaks, rotate first, rewrite history with regex patterns rather than literal lists, and add a pre-commit scanner so it never happens again.
Specific Adaptation to Imposed Demands — you get good at exactly what you practise. Tests and staging only prepare a system for the conditions they simulate.
Red, green, refactor is less about tests than about tight feedback — and in the age of coding agents, a failing test is the clearest instruction you can give.