From bdf7d42d795361a8af4bde7c0137b45617898e45 Mon Sep 17 00:00:00 2001 From: AlexPaiva Date: Thu, 30 Jul 2026 22:55:28 +0100 Subject: [PATCH] fix(build): skip root-level test dirs when packaging examples 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. --- context/skip-patterns.yaml | 5 +++++ scripts/lib/tests/skip-patterns.test.js | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/context/skip-patterns.yaml b/context/skip-patterns.yaml index 6a28b1f4..873f5c83 100644 --- a/context/skip-patterns.yaml +++ b/context/skip-patterns.yaml @@ -149,6 +149,11 @@ global: regex: # Skip .env files but allow .env.example - ^.env(?!\.example$) + # Skip a root-level test/ or tests/ dir. The `/test/` substring above only + # catches nested ones, because shouldSkip is given a path relative to the + # example root, so the root dir has no leading slash to match on. The + # separator class also covers path.relative output on Windows. + - ^tests?[/\\] # Example-specific overrides # Add patterns here to skip files only for specific examples diff --git a/scripts/lib/tests/skip-patterns.test.js b/scripts/lib/tests/skip-patterns.test.js index 55a02869..5c776782 100644 --- a/scripts/lib/tests/skip-patterns.test.js +++ b/scripts/lib/tests/skip-patterns.test.js @@ -20,6 +20,18 @@ describe('shouldSkip', () => { expect(shouldSkip('.env.example', patterns)).toBe(false); }); + it('skips a root-level test dir, not only nested ones', () => { + const patterns = mergeSkipPatterns({ + includes: ['/test/'], + regex: [new RegExp('^tests?[/\\\\]')], + allow: [], + }); + expect(shouldSkip('app/test/helpers.py', patterns)).toBe(true); + expect(shouldSkip('test/test_api.py', patterns)).toBe(true); + expect(shouldSkip('tests/example.spec.ts', patterns)).toBe(true); + expect(shouldSkip('testing/settings.py', patterns)).toBe(false); + }); + it('keeps files matching no pattern', () => { const patterns = mergeSkipPatterns(globalPatterns); expect(shouldSkip('Sources/App.swift', patterns)).toBe(false);