<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-playwright-tests-leak-data-and-how-to-stop-it--58jrawqlh" -->

---
title: How Playwright Tests Leak Data (and How to Stop It)
description: Playwright test artifacts (traces, screenshots, videos, HAR files, storageState.json, console logs, reporter output) can leak credentials, tokens, and PII even...
canonical: https://daily.dev/posts/how-playwright-tests-leak-data-and-how-to-stop-it--58jrawqlh
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How Playwright Tests Leak Data (and How to Stop It) | daily.dev
og:description: Playwright test artifacts (traces, screenshots, videos, HAR files, storageState.json, console logs, reporter output) can leak credentials, tokens, and PII even...
og:url: https://daily.dev/posts/how-playwright-tests-leak-data-and-how-to-stop-it--58jrawqlh
og:image: https://api.daily.dev/og/posts/58JrAWQLh.png
og:image:alt: How Playwright Tests Leak Data (and How to Stop It)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How Playwright Tests Leak Data (and How to Stop It)

**[Currents](https://daily.dev/sources/currents)** · 17 min read · 0 upvotes · 0 comments

## Summary

Playwright test artifacts (traces, screenshots, videos, HAR files, storageState.json, console logs, reporter output) can leak credentials, tokens, and PII even when secrets hygiene at the application level is solid. The gap sits in test tooling: trace.zip files capture headers, cookies, and DOM snapshots; videos record everything on screen; console.log and test.info().attach() calls expose values in retries and reports; worker-scoped fixtures and env vars can surface tokens in step annotations. A risk table ranks artifacts from CRITICAL (trace.zip, storageState.json) to LOW/MEDIUM (reporter logs). Mitigations include using retain-on-failure trace mode, scrubbing artifacts before upload, selective header injection via page.route(), building a redacting reporter, disabling DOM snapshots, clearing cookies between tests, using CI-native secrets or external vaults with short-TTL tokens, disciplined .gitignore patterns for .env variants, and an incident-response checklist (rotate credentials, purge CI artifacts, scrub git history with git-filter-repo, request deletion from dashboards) if a leak is discovered.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://currents.dev/posts/playwright-avoid-data-leak>

## Questions this post answers

### How can I stop Playwright traces from leaking auth tokens and cookies?

Playwright trace.zip archives serialize network headers, cookies, and DOM snapshots, so any Authorization headers, bearer tokens, or Set-Cookie values used during a test get captured. Use trace: 'retain-on-failure' instead of 'on' so traces are only persisted for failing tests, delay starting tracing until after login, or use startChunk()/stopChunk() to exclude sensitive segments, and disable snapshots: false to remove DOM data.

_daily.dev surfaces practical fixes like this for teams hardening their Playwright CI pipelines._

### Does Playwright have a built-in way to strip response bodies from HAR files?

Yes, the context.tracing.startHar() API added in Playwright 1.60 supports a content: 'omit' option that strips response bodies while still recording request and response headers, reducing exposure of credentials or PII compared to full HAR capture with recordHar.

_Developers tracking Playwright API additions like this can follow release changes on daily.dev._

### Why does CI secret masking fail to protect credentials in Playwright test reports?

CI secret masking only scans log output, so it never touches trace archives, HAR files, or storageState.json where a secret can be serialized in plaintext. Masking also breaks if a secret is base64-encoded, truncated, or concatenated with other strings before being logged, since the masking engine no longer recognizes the original value.

_daily.dev helps teams stay current on CI security gaps like this before they ship a leak._

## Similar posts on daily.dev

- [How to protect secrets when coding agents deploy your app](https://daily.dev/posts/how-to-protect-secrets-when-coding-agents-deploy-your-app-npq9apqlk) · Flavio Copes · 2 upvotes · 1 comments
- [Preventing secret leakage in CI/CD environments](https://daily.dev/posts/preventing-secret-leakage-in-ci-cd-environments-tveiielvq) · Security Boulevard · 2 upvotes · 0 comments
- [Playwright Test Observability: Run History, Flakes, Traces](https://daily.dev/posts/playwright-test-observability-run-history-flakes-traces-ipd5adv9b) · Currents · 0 upvotes · 0 comments
- [How to analyze Playwright traces](https://daily.dev/posts/how-to-analyze-playwright-traces-zowzprzht) · RUBYLAND · 0 upvotes · 0 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#cicd](https://daily.dev/tags/cicd), [#appsec](https://daily.dev/tags/appsec), [#secrets-management](https://daily.dev/tags/secrets-management)

[View this post on daily.dev](https://daily.dev/posts/how-playwright-tests-leak-data-and-how-to-stop-it--58jrawqlh)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How Playwright Tests Leak Data (and How to Stop It)","url":"https://daily.dev/posts/how-playwright-tests-leak-data-and-how-to-stop-it--58jrawqlh","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-playwright-tests-leak-data-and-how-to-stop-it--58jrawqlh"},"datePublished":"2026-09-06T08:56:39.280Z","dateModified":"2026-09-06T13:10:51.388Z","description":"Playwright test artifacts (traces, screenshots, videos, HAR files, storageState.json, console logs, reporter output) can leak credentials, tokens, and PII even...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8737612d5349b7dfde00ea6571838e01?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8737612d5349b7dfde00ea6571838e01?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Currents","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Currents","logo":"https://media.daily.dev/image/upload/s--RxsiMZ1S--/f_auto,q_auto/v1788684994/logos/currents?_a=BAMAMicg0","url":"https://daily.dev/sources/currents"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-playwright-tests-leak-data-and-how-to-stop-it--58jrawqlh","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"testing,cicd,appsec,secrets-management","timeRequired":"PT17M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Currents","item":"https://daily.dev/sources/currents"},{"@type":"ListItem","position":3,"name":"How Playwright Tests Leak Data (and How to Stop It)"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-playwright-tests-leak-data-and-how-to-stop-it--58jrawqlh#faq","mainEntity":[{"@type":"Question","name":"How can I stop Playwright traces from leaking auth tokens and cookies?","acceptedAnswer":{"@type":"Answer","text":"Playwright trace.zip archives serialize network headers, cookies, and DOM snapshots, so any Authorization headers, bearer tokens, or Set-Cookie values used during a test get captured. Use trace: 'retain-on-failure' instead of 'on' so traces are only persisted for failing tests, delay starting tracing until after login, or use startChunk()/stopChunk() to exclude sensitive segments, and disable snapshots: false to remove DOM data. daily.dev surfaces practical fixes like this for teams hardening their Playwright CI pipelines."}},{"@type":"Question","name":"Does Playwright have a built-in way to strip response bodies from HAR files?","acceptedAnswer":{"@type":"Answer","text":"Yes, the context.tracing.startHar() API added in Playwright 1.60 supports a content: 'omit' option that strips response bodies while still recording request and response headers, reducing exposure of credentials or PII compared to full HAR capture with recordHar. Developers tracking Playwright API additions like this can follow release changes on daily.dev."}},{"@type":"Question","name":"Why does CI secret masking fail to protect credentials in Playwright test reports?","acceptedAnswer":{"@type":"Answer","text":"CI secret masking only scans log output, so it never touches trace archives, HAR files, or storageState.json where a secret can be serialized in plaintext. Masking also breaks if a secret is base64-encoded, truncated, or concatenated with other strings before being logged, since the masking engine no longer recognizes the original value. daily.dev helps teams stay current on CI security gaps like this before they ship a leak."}}]}
```

