-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Problem
When using bktec with Jest, tests in directories containing parentheses (e.g., (main)) or brackets (e.g., [catalogId]) are silently excluded from test runs. This commonly affects Next.js App Router projects which use these characters as part of their routing conventions:
(folderName)- Route groups (organizational folders excluded from URL path)[param]- Dynamic route segments
Reproduction
Given a Next.js project structure like:
src/app/(main)/page.test.tsx
src/app/(main)/[catalogId]/product.test.tsx
src/app/(main)/layout.test.tsx
Running bktec with Jest will not execute any tests in these directories. The Jest output shows:
Pattern: src/app/(main)/page.test.tsx - 0 matches
Root Cause
Jest interprets CLI arguments as regex patterns. When paths containing (main) are passed to Jest, the parentheses are interpreted as regex capture groups instead of literal characters. This causes the pattern matching to fail.
For example:
src/app/(main)/test.tsxis interpreted as a regex where(main)is a capture group- This doesn't match the literal directory path
src/app/(main)/test.tsx
Expected Behavior
Test files in directories with parentheses and brackets should be discovered and executed correctly.
Environment
- Next.js App Router projects
- Any Jest version
- bktec wrapping Jest
Workaround
Currently, there is no workaround other than renaming directories to avoid special characters, which is not feasible for Next.js App Router projects where these naming conventions are required.