Skip to content

fix(cli)!: resolve include patterns relative to Playwright config directory#1309

Merged
sorccu merged 6 commits into
next/v8from
simo/red-543-resolve-include-patterns-relative-to-the-playwright-config
May 21, 2026
Merged

fix(cli)!: resolve include patterns relative to Playwright config directory#1309
sorccu merged 6 commits into
next/v8from
simo/red-543-resolve-include-patterns-relative-to-the-playwright-config

Conversation

@sorccu
Copy link
Copy Markdown
Member

@sorccu sorccu commented May 21, 2026

Summary

  • Include patterns (checks.include and per-check PlaywrightCheckProps.include) are now resolved relative to the Playwright config file's directory instead of the workspace root (Session.basePath). This fixes incorrect file matching when the Playwright config lives in a subdirectory (e.g. monorepo setups).
  • pnpm patches auto-include adjusted to compute a relative pattern from the Playwright config directory back to the project root, so patches/*.patch files are still bundled correctly.
  • Default ignore skip detection now recognizes explicit includes of node_modules or .git regardless of path form (parent traversal, absolute paths), not just patterns starting with the directory name.

Other changes

  • .git ignore pattern changed from .git/** to **/.git/** for cwd-independence, consistent with **/node_modules/**.

Breaking change

include patterns are now resolved relative to the directory containing the Playwright config file, not the project root. Users with playwrightConfigPath pointing to a subdirectory who wrote include patterns relative to the project root will need to adjust them.

Test plan

  • Existing bundling tests pass (PW config at root — basePath === dir, no behavior change)
  • New test: include patterns resolve relative to subdirectory PW config (decoy file at root proves old behavior is gone)
  • New test: pnpm patches auto-included when PW config is at root
  • New test: pnpm patches auto-included when PW config is in a subdirectory
  • New test: absolute paths in include work via MaC .check.ts
  • getAutoIncludes unit tests updated for new globCwd parameter + subdirectory cases

🤖 Generated with Claude Code

sorccu and others added 5 commits May 22, 2026 02:31
…ectory

Include glob patterns in bundlePlayWrightProject were resolved relative
to Session.basePath (workspace root) instead of the Playwright config
file's directory. This caused patterns like 'fixtures/**' to look in the
wrong location when the Playwright config lived in a subdirectory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…right config

Update getAutoIncludes unit tests for the new globCwd parameter and add
coverage for subdirectory scenarios. Add integration test with a fixture
where the Playwright config lives in a subdirectory to verify include
patterns resolve correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…undles

Verify that pnpm patch files are auto-included in Playwright check
bundles for both the root case and the subdirectory case where the
Playwright config lives in a nested directory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verify that absolute file paths in the PlaywrightCheck include property
are supported. Uses a .check.ts file with import.meta.url to compute
the absolute path dynamically at runtime.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…form

The skipIf checks for default node_modules and .git ignore patterns only
matched patterns starting with the directory name. This missed patterns
using parent traversal or absolute paths. Use a helper that checks for
the directory name as a path segment anywhere in the pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sorccu sorccu force-pushed the simo/red-543-resolve-include-patterns-relative-to-the-playwright-config branch from 812ffd8 to e99399c Compare May 21, 2026 17:32
…indows

path.join produces backslash paths on Windows, but glob requires forward
slashes. Normalize patterns in findFilesWithPattern before passing them
to glob.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sorccu sorccu merged commit 5bf366e into next/v8 May 21, 2026
8 checks passed
@sorccu sorccu deleted the simo/red-543-resolve-include-patterns-relative-to-the-playwright-config branch May 21, 2026 17:55
@sorccu sorccu mentioned this pull request May 22, 2026
sorccu added a commit that referenced this pull request May 22, 2026
…ectory (#1309)

* fix(cli)!: resolve include patterns relative to Playwright config directory

Include glob patterns in bundlePlayWrightProject were resolved relative
to Session.basePath (workspace root) instead of the Playwright config
file's directory. This caused patterns like 'fixtures/**' to look in the
wrong location when the Playwright config lived in a subdirectory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test(cli): add tests for include pattern resolution relative to Playwright config

Update getAutoIncludes unit tests for the new globCwd parameter and add
coverage for subdirectory scenarios. Add integration test with a fixture
where the Playwright config lives in a subdirectory to verify include
patterns resolve correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test(cli): add integration tests for pnpm patches auto-inclusion in bundles

Verify that pnpm patch files are auto-included in Playwright check
bundles for both the root case and the subdirectory case where the
Playwright config lives in a nested directory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test(cli): add integration test for absolute paths in include

Verify that absolute file paths in the PlaywrightCheck include property
are supported. Uses a .check.ts file with import.meta.url to compute
the absolute path dynamically at runtime.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(cli): detect explicit include of ignored dirs regardless of path form

The skipIf checks for default node_modules and .git ignore patterns only
matched patterns starting with the directory name. This missed patterns
using parent traversal or absolute paths. Use a helper that checks for
the directory name as a path segment anywhere in the pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(cli): normalize include patterns to forward slashes for glob on Windows

path.join produces backslash paths on Windows, but glob requires forward
slashes. Normalize patterns in findFilesWithPattern before passing them
to glob.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant