Skip to content

fix(build): skip root-level test dirs when packaging examples - #304

Open
AlexPaiva wants to merge 1 commit into
PostHog:mainfrom
AlexPaiva:alex/skip-top-level-test-dirs
Open

fix(build): skip root-level test dirs when packaging examples#304
AlexPaiva wants to merge 1 commit into
PostHog:mainfrom
AlexPaiva:alex/skip-top-level-test-dirs

Conversation

@AlexPaiva

Copy link
Copy Markdown

shouldSkip in scripts/lib/example-processor.js receives a path relative to the example root (collectFiles computes it with path.relative(baseDir, fullPath)), therefore the global /test/ pattern only matches nested directories like app/test/. A root-level test/ or tests/ has no leading slash and never matches.

Running the current patterns through the repo's own shouldSkip:

PACKAGED test/test_api.py
PACKAGED tests/test_api.py
PACKAGED tests/example.spec.ts
SKIPPED  app/test/foo.py

So example-apps/next-app-router/tests ships its Playwright specs in the skill output today, and any example that adds tests at the root would do the same.

This adds an anchored regex for the root-level case and a regression test covering nested, root-level, and the testing/ near-miss. The separator class covers path.relative output on Windows.

I considered normalizing the path with leading and trailing separators before matching, which would fix the general class rather than this one case, but it changes behaviour for every existing pattern and seemed like the wrong call for an outside contribution. Happy to do it that way instead if preferred.

Please note that the suite has 6 failing test files on main before this change (bundle-writer.test.js has an assertion failure). Unrelated, and this just adds one passing test on top.

shouldSkip gets a path relative to the example root, so the global
`/test/` pattern only matches nested dirs like app/test/. A root-level
test/ or tests/ has no leading slash and never matches, so
next-app-router/tests ships its Playwright specs in the skill output.

Adds an anchored regex for the root-level case, plus a regression test
covering nested, root-level and the testing/ near-miss.
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