A good report answers three questions: what failed, why, and whether it failed before. Each failure needs the assertion message, a trace, a screenshot or video for failed tests, a correlation id, the build version, the environment and the shard number. Reporting is built in layers for different readers, and raw results (JSON, JUnit XML) are stored apart from the HTML so that history and metrics do not depend on one tool.
System design · Reporting
A test is red. How many minutes does it take to find the cause from the report alone?
The nightly run of 800 tests is over: 14 are red. The report is a list of names, each with "Error: expect(received).toBe(expected)". To understand what happened, the engineer opens CI, looks for artifacts, asks in chat which build it is and guesses which service to search the logs in. Each failure takes twenty minutes, and there is no strength left for a real regression. A report that only lists test colours gives the minimum. A good report answers three questions: what failed, why, and whether it failed before.
How it works and why. Different readers need different detail, so reporting is built in layers, each answering its own question, not one "universal" report. The engineer investigating a failure wants steps, DOM, network and console. The team wants to see a trend: what is unstable, what is slow. The commit author wants a short message "your PR broke this" with a link. Management needs a few numbers over time. The lower layer feeds the upper one, so raw results must be kept in a neutral format.
Four layers of reporting
Figure 1. Each layer answers its own question. All are fed from the same raw results.
What every failure needs.
The assertion message with the stack: which line and which expectation.
Playwright trace: steps, DOM snapshots before and after an action, network requests, console.
A screenshot and a video if needed: they take space, so usually only for failed tests.
The correlation id of the requests, to find backend logs.
The environment, the build version, the shard number: without these a failure cannot be reproduced.
Example: from a list of reds to a report that explains. A configuration that collects artifacts only where they are needed and puts raw results apart from the HTML:
Three reporters give three different outputs: HTML for a person, JUnit XML for CI systems, JSON for your own analytics. The metadata field is included in the reports and serialized into the JSON report, so the build version and the environment are recorded together with the results. With sharding each shard writes a blob report and then they are merged into one:
# on each shard (config has reporter: 'blob' in CI)
npx playwright test --shard=1/4
# after all shards: one HTML report
npx playwright merge-reports --reporter html ./all-blob-reports
One failure in two reports
Weak
Only a colour
Test transfer completes
Error expect(received).toBe(expected)
Trace none
Build unknown
Strong
Answers the questions
Test transfer completes
Error expected 201, received 500
Trace steps, network, console
Build sha, shard 3/4, staging
Figure 2. The difference is whether the reader can start investigating without further questions.
Notifications. A message about every failure in a shared channel turns into noise nobody reads within a week. What works is addressing: to the PR author or the area owner, and into the shared channel only failures on main. The message is short: how many failed, the first few names, a link to the report and to the commit.
Limits and alternatives. The built-in Playwright HTML report is good for dissecting one failure but does not keep history between runs: trends need an external store. Here the choice is between ready services (Allure, ReportPortal, runner cloud dashboards) and your own database with JSON results. A ready one starts faster, your own is more flexible. Raw JSON or JUnit XML must be kept in any case: then the choice of a reporting tool does not tie you to it forever.
Common mistakes.
Storing a video for every test: gigabytes nobody opens. For failed ones it is enough.
Artifacts live only on the CI agent and vanish when the job ends: they must be uploaded as artifacts.
A notification for every failure in a shared channel: within a week the channel is muted.
A report without the build version and the environment: the failure cannot be reproduced.
Only HTML without raw results: there is nothing to build history and metrics from later.
Check yourself
Why does the config use trace: 'on-first-retry' together with video: 'retain-on-failure' instead of recording everything always?
Answer
Recording a trace and a video costs execution time and space. Tests that passed on the first attempt need no artifacts. on-first-retry gives a trace exactly for a test that failed and was repeated, and the video is kept only for failed ones. So diagnostics exist where they are needed and the rest do not pay for them.
Four shards have finished, each with its own HTML report. How to get one report and why not stitch them by hand?
Answer
Each shard writes a blob report (reporter: 'blob'), and after all shards npx playwright merge-reports --reporter html merges them into one report with correct totals and tests from all shards. Stitching HTML by hand gives wrong counters and loses attachments.
Related lessons: "Test system metrics", "Observability and testing", "Feedback speed and cost".
In the interview.Junior: A report must show what failed and why: the error message, the trace, a screenshot. In Playwright that is the HTML report with the trace viewer. Middle/Senior: I build reporting in layers: an HTML report with a trace for investigation, with the build version and environment written to the metadata of the reports, result history for trends, addressed notifications to the change author, a dashboard for the team. I keep raw JSON or JUnit results separately so analytics does not depend on one reporting tool.
Test system metrics
Test system metrics answer three questions: is feedback fast, do we trust the result, do we catch what matters. They are pipeline time by p50 and p95, flaky rate, pass rate on main and escaped defects. An average hides the tail of slow runs, and a metric turned into a target starts to be distorted, so metrics are read together and code coverage is not treated as quality.
System design · Metrics
The average run takes 10 minutes, yet developers complain about 25. Who is right?
The dashboard shows "average pipeline time 10 minutes", and it seems all is well. But every fifth run takes 25 minutes because of a slow shard, and these are the runs developers remember. Metrics exist to see such things before complaints, but a wrong metric is worse than none: it creates a calm that is not there. The lesson covers what to measure in a test system, how to compute it and what not to measure.
How it works and why. Test system metrics answer three questions: is feedback fast, do we trust the result, do we catch what matters. Speed: pipeline time. Trust: flaky rate and pass rate on main. Effectiveness: escaped defects, that is bugs that reached production. Each metric is tied to a decision: if the number changes, what do we do differently? A metric without a decision is decoration.
Metric
What it shows
Starting reference
Pipeline time p50 and p95
Feedback speed
PR within 10-15 min
Flaky rate
Share of tests that passed only on a retry
Below 1-2 percent
Pass rate on main
Health of the main branch
Close to 100 percent
Escaped defects
Bugs found in production
Trend down
Time to investigate a failure
How long analysis takes
Trend down
Cost of a run
CI spend
Under control
The references are a starting point, not an industry standard: they are chosen for the team and checked for whether they really influence decisions.
Why p95 and not the average. The average mixes fast and slow runs into one number. The p95 percentile says: 95% of runs are faster than this value, so the remaining 5% is the tail. Developers feel exactly the tail: every slow run is a stalled PR.
One sample, two numbers
Average
10 minutes
Looks fine. Hides that a part of the runs is slow.
p95
25 minutes
Shows the tail: this is the delay the team feels.
Figure 1. Both numbers are correct. The mistake is to count only the first and not look at the second.
Example: computing flaky rate and p95 from a JSON report. The Playwright JSON reporter stores a final status for every test (expected, unexpected, flaky, skipped). A small script turns the file into two metrics:
(report is the parsed results.json, pipelineMinutes is an array of run durations from CI.) Metrics make sense over weeks of history, not one run: a single run is an anecdote, a trend is data.
Escaped defects: the most honest metric. Every production bug is worth analysing with three questions: could a test have caught it, at which level (unit, API, e2e, manual check) and why it did not. The answers give concrete actions: add a check at a lower level, fix the data, update a checklist. This is more useful than the abstract "increase coverage".
Limits and alternatives. Code coverage shows that lines were executed, not what was verified: a test without meaningful assertions also gives coverage. For e2e, coverage of business risks is more useful: all payment methods, currencies, transfer statuses. A metric turned into a target (for example, "flaky rate below 1%") starts to distort: tests are simply deleted or hidden in quarantine. So metrics are read together: a falling flaky rate must come with a steady number of tests and escaped defects. For feedback speed a separate metric helps too: time from commit to the first red result.
Common mistakes.
Looking only at average time: the tail is what developers feel.
Counting code coverage as quality: a high percentage without checks guarantees nothing.
Metrics on a single run: they jump and show no trend.
A target on a metric without watching side effects: a falling flaky rate because tests were deleted.
Check yourself
There are 100 runs: 90 at 8 minutes and 10 at 40 minutes. Why does the average (11.2 min) mislead and what does p95 show?
Answer
The average smears slow runs over the whole sample and looks acceptable. p95 is the value below which 95% of runs fall: here it is about 40 minutes, because the slow runs are 10% of the sample. This delay stalls PRs, so p95 reflects the team's experience better.
The team set a goal "flaky rate below 1%" and in a month it fell to 0.3%. What else to check before celebrating?
Answer
Whether the number of tests fell, whether unstable tests were moved to quarantine without a fix, whether escaped defects and investigation time are growing. If the numbers improved by removing coverage, the goal was met formally while quality fell.
Related lessons: "A report that helps find the cause", "The process of fighting flakiness: detect, isolate, fix", "Feedback speed and cost".
In the interview.Junior: I look at pipeline time, flaky rate and pass rate on main. They show the speed and reliability of the tests. Middle/Senior: I read pipeline time at p95 because developers feel the tail. The most value comes from analysing escaped defects: for each I ask at which level a test should have caught it and build the plan from that. I do not treat code coverage as quality, and I read metrics together so a target does not distort the result.
Observability and testing
Observability is the ability to understand the internal state of a system from its external signals: logs, metrics and traces. A metric says that something got worse, a trace shows where, a log explains why. They are tied together by a correlation id or trace id that the test generates, puts into the request and saves in the report. traceparent requires the W3C Trace Context format; services ignore an arbitrary string.
System design · Observability
A test got a 500 from the transfer. In which of five services to look for the cause?
In a microservice system a transfer request passes through the gateway, the transfers service, the accounts service, anti-fraud and a queue. The test sees only a "500" at the entrance. Without a shared identifier, the investigation is a needle search in five log streams by time: close, but not certain. With an identifier the test itself put into the request, the logs of all services are found with one search. The lesson covers what observability is, how to pass an identifier from a test and how else QA uses these signals.
How it works and why. Observability is the ability to understand the internal state of a system from its external signals: logs (what happened, event by event), metrics (numbers over time: error rate, latency) and traces (the path of one request across services). For QA they answer different questions: a metric says something is wrong, a trace shows where, a log explains why. What ties them together is a request identifier: a correlation id or trace id. Each service takes it from the incoming request, writes it into every log line and passes it on. Then the logs of scattered services are gathered into one story.
One id through the whole system
Figure 1. The test is the start of the chain: it knows the id in advance and can put it in the report.
Example: send an id and store it in the report. The simplest option is a custom header:
The header name depends on the project: it may be X-Request-Id, X-Correlation-Id or the standard traceparent from W3C Trace Context. An arbitrary string won't do for traceparent: the value has the format 00-<trace-id, 32 hex>-<parent-id, 16 hex>-01, otherwise services ignore it and start a new trace. So for the standard header the id is generated in the right format:
Now the report has the trace id next to the failure, and it can be pasted into the tracing system or log search. Some tools (for example OpenTelemetry with default settings) pick up traceparent from the incoming request and continue the trace, so in the system the test shows up as the start of the chain. Whether a service supports this must be checked on the project: if not, fall back to your own header.
How else QA uses observability.
Checking side effects. Not only the API response but also that the event reached the queue and the audit log with the same id.
Release check. After a deploy, look at the error rate and latency in metrics: tests may be green while production is already degrading.
Synthetic monitoring. A small set of scenarios (login, viewing a balance on a test account) that regularly hit production and alert on failure.
Limits and alternatives. An identifier helps only if every service writes it. If one of them loses the id (an asynchronous worker without context propagation), the chain breaks, and that is also a finding for QA: check that the id reaches the message handler. Logs with personal data must not end up in test reports: the id is not a secret, but a card number or a token in a log is a security problem. Synthetic checks in production must run on a dedicated test account with safe actions, not create real transfers.
Common mistakes.
Generating an id but not storing it in the report: after a failure there is nowhere to get it from.
Passing an arbitrary string in traceparent: the vendor ignores an invalid value and starts a new trace.
Relying only on the API response and not looking at the queue and the audit log.
Putting actions with real money into synthetic checks.
Check yourself
A test sends traceparent: e2e-123. The service logs for this id are empty. Why and how to fix it?
Answer
traceparent has the format 00-<32 hex>-<16 hex>-01. An arbitrary string is invalid, so services ignore the header and create their own trace id. You need to generate proper values (32 and 16 hex characters), send them and store the trace id in the report. Or use a custom header such as X-Request-Id if the project supports it.
How do a metric, a trace and a log differ for investigating a test failure?
Answer
A metric shows that something got worse (error rate, latency) and when. A trace shows the path of one request across services and where it slowed or failed. A log explains what exactly happened at that place. Investigation usually goes from metric to trace to log, and the request identifier ties them together.
Related lessons: "A report that helps find the cause", "A microservices testing strategy", "Eventual consistency and sagas in tests".
In the interview.Junior: Observability is logs, metrics and traces. A correlation id passes through all services and the request logs can be found by it. Middle/Senior: The test generates the id itself in the right format (for traceparent it is 32 and 16 hex characters) and stores it in the report, so within a minute I find the logs of all services for a specific failure. After a release I use metrics and synthetic checks as a continuation of testing, and check side effects (queue, audit log) by the same id.