Skip to content

fix(cli): gitignore .playwright-cli on workspace install - #42314

Closed
Burak Keskin (official-burak) wants to merge 1 commit into
microsoft:mainfrom
official-burak:fix/cli-gitignore-output-dir
Closed

fix(cli): gitignore .playwright-cli on workspace install#42314
Burak Keskin (official-burak) wants to merge 1 commit into
microsoft:mainfrom
official-burak:fix/cli-gitignore-output-dir

Conversation

@official-burak

@official-burak Burak Keskin (official-burak) commented Aug 19, 2026

Copy link
Copy Markdown

Fixes #42307

playwright-cli install creates .playwright/ for config and later writes traces, snapshots, screenshots, and PDFs under .playwright-cli/. A trace records request headers and bodies, so an authenticated session can leave credentials in the working tree as an untracked directory that git add -A will pick up.

create-playwright already appends /playwright/.auth/ to .gitignore for the same reason. This does the equivalent for the CLI output directory:

  • append .playwright-cli/ to .gitignore on workspace install (idempotent; skips -g)
  • leave existing .gitignore contents intact

.playwright/ (project config) is left alone.

Test

npx playwright test --config=tests/mcp/playwright.config.ts --project=chrome -g "gitignores|appends CLI output"

  2 passed

The rest of cli-misc is unchanged except a check that --skills -g does not create a workspace .gitignore.

Traces and snapshots under that directory can include request headers
and bodies. install left it untracked, so git add -A would pick it up.
@official-burak

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@official-burak

Copy link
Copy Markdown
Author

Closing this — CONTRIBUTING requires the issue to be assigned before a PR. Thank you.

try {
existing = await fs.promises.readFile(gitignorePath, 'utf8');
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== 'ENOENT')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A failed .gitignore write now fails the whole install. Let's make it best-effort.

It writes .gitignore unconditionally, even outside a git repo. playwright-cli install runs in any directory; this creates a .gitignore where none may be wanted. Let's only add the line to existing .gitignore.

@yury-s

Copy link
Copy Markdown
Member

Will be fixed by #42318

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

playwright-cli: install --skills leaves .playwright-cli/ untracked, and traces there can hold credentials

2 participants