The first time I saw browser tests used seriously was on an in-house reporting system built in React. The team behind it treated dashboards as code: every report lived in the repository, went through review and shipped like any other change. Playwright checked each changed report in a real browser before it went out, and that is what let them get changes into the reports faster.
Recently I brought the same approach to this website, working with Claude Code: I decided what to test and why, and it wrote and ran the tests with me. The site's existing test suite was green. Every check passed. And that raised the only question that matters: could any of those checks ever go red?
Working through it, I kept running into lessons I learned in data quality first. Here are six of them.
Shape is not behavior
The site's first test opened every page once and read the HTML: the right sections, the right counts, no JavaScript errors. Useful, and very close to a schema test: the columns exist, the types are right, nothing is null that should not be.
But it never clicked anything. A filter that stopped filtering, a Back button that stopped working, a menu that did not open on a phone: all of them would have passed.
The new test opens the site in a real browser, at desktop and at phone size, and does what a visitor does. It opens a stage on the architecture map and goes back, searches for a tool, switches a filter, and reloads the page to check the choice was remembered.
In data, schema tests tell you a table looks right. Business-logic tests tell you it behaves right: revenue reconciles with the finance system, a customer never has two active rows, every order joins to a customer. You need both, and the second kind catches the failures people actually notice.
Don't hardcode your expectations
Hard-coded numbers rot. If my test said "the resources page shows 28 cards", it would fail the day I added a 29th, and I would soon learn to ignore it. Instead, the test reads its expected counts from the same data file the site renders from. Adding content does not break it. A page that silently drops content does.
Thresholds in data tests work the same way. "Row count above 10,000" was right the month someone wrote it. Compare against the source system, against yesterday, or against a rolling average, so the expectation moves with the data and a failure means something.
Break it on purpose before you trust it
Once the new test was written, we broke the site on purpose, in a copy: we switched off the Back button handling on the map and the phone menu. The test went red on exactly those flows. Only then did I believe the green.
A test you have never seen fail might be testing nothing: the wrong column, a filter that excludes every row, a condition that is always true.
Before trusting a new data test, plant the problem it is meant to catch in a development copy, a duplicate key, a null, an orphan row, and watch it fail. It takes five minutes and turns a green check from hope into evidence.
Don't pollute your own metrics
To a web page, a browser test is just another visitor. It loads the analytics script like anyone else. So my test blocks every outside request except the fonts: it runs offline and never shows up as a visit.
Google Analytics 4 filters known bots on its own, but you cannot see what it removed or turn the filter off (Google Analytics Help). I would rather block my own test traffic at the source than trust a list I cannot inspect.
The same goes for any synthetic traffic in a data platform: load tests, QA accounts, demo tenants, health checks. Flag it at the source and filter it, or block it, before it reaches a metric. Cleaning it out afterwards is always harder.
When a test fails, keep the evidence
A red light tells you something broke, not what. When a flow fails, my test keeps a Playwright trace: a recording you can step through action by action, with a snapshot of the page and its log and network requests at each step (Playwright docs). Passing flows keep nothing, so the evidence costs nothing until the day you need it.
dbt has the same idea for data. With store_failures switched on, a test saves the records that failed it to a table named after the test (dbt docs). The investigation starts with the bad rows in front of you, not with rewriting the test query by hand.
Match the cadence to the cost
The fast checks run on every pull request: one browser, desktop and phone, about five seconds on my laptop. A slower run happens once a week in three browser engines and saves a screenshot of every page. Same checks, different cadence, chosen by what they cost and how quickly the thing they guard tends to break.
In a data platform: blocking checks in CI on the models a change touches, freshness, volume and distribution monitors on a schedule, and the expensive reconciliations nightly or weekly. Running everything on every change makes CI slow, and slow CI is the CI people learn to work around.
The takeaway
A test earns trust only after you have seen it fail. Before you add the next check, on a website or in a warehouse, ask two questions: what failure is this meant to catch, and have I watched it catch it?
Further reading
- Playwright best practices: the first principle is "test user-visible behavior", the shape versus behavior point from the browser side.
- dbt: Add data tests to your DAG: a data test returns the failing records, and zero rows means the assertion holds.
- Martin Fowler, Self Testing Code: write a test that exposes the bug, and only then fix it.
- State of Mutation Testing at Google (Petrović and Ivanković, ICSE 2018): "break it on purpose" done systematically, adding small faults to the code and checking the tests catch them.
- Video: Testing Web Applications with Playwright, Debbie O'Brien of Microsoft at Craft Conference 2022.
- Video: Breaking the mold: A smarter approach to data testing, a Coalesce 2024 talk on the dbt Labs channel.
- On this site: the Quality checks and Data observability pages of the Architecture map, with Great Expectations, Soda, dbt tests, Elementary and more.