Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ coverage
e2e/docker
android
ios

.worktrees/
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ ios/
patches/
scripts/

.worktrees/

.bettercodehub.yml
.buckconfig
.gitattributes
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
testPathIgnorePatterns: ['e2e', 'node_modules'],
testPathIgnorePatterns: ['/e2e/', '/node_modules/', '/(^|\\/)\\.worktrees\\//'],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verifies current vs proposed regex behavior on representative paths.
python - <<'PY'
import re

current = re.compile(r'/(^|\/)\.worktrees\/')
proposed = re.compile(r'(^|[/\\])\.worktrees([/\\]|$)')

samples = [
    "/repo/.worktrees/feature/app/foo.test.ts",
    "/repo/app/foo.test.ts",
    r"C:\repo\.worktrees\feature\app\foo.test.ts",
]

for s in samples:
    print(s)
    print("  current :", bool(current.search(s)))
    print("  proposed:", bool(proposed.search(s)))
PY

Repository: RocketChat/Rocket.Chat.ReactNative

Length of output: 289


🏁 Script executed:

#!/bin/bash
# Check the jest.config.js file to see the current state
cd /repo && head -20 jest.config.js

Repository: RocketChat/Rocket.Chat.ReactNative

Length of output: 133


🏁 Script executed:

#!/bin/bash
# Also check if there are any Jest documentation or comments in the file
cd /repo && wc -l jest.config.js

Repository: RocketChat/Rocket.Chat.ReactNative

Length of output: 133


🏁 Script executed:

#!/bin/bash
# Find jest.config.js in the repository
git ls-files | grep -E 'jest\.config\.(js|ts|json)$'

Repository: RocketChat/Rocket.Chat.ReactNative

Length of output: 92


🏁 Script executed:

#!/bin/bash
# Read the jest.config.js file content
if [ -f "jest.config.js" ]; then
  cat -n jest.config.js
fi

Repository: RocketChat/Rocket.Chat.ReactNative

Length of output: 896


🌐 Web query:

Jest testPathIgnorePatterns regex behavior and how it matches file paths

💡 Result:

Jest's testPathIgnorePatterns is an array of regexp pattern strings matched against all test paths before executing tests. If a test path matches any pattern, the test is skipped. Key behaviors: - Patterns match against the full absolute file path of potential test files. - Uses JavaScript RegExp syntax, not glob patterns (e.g., no or !; use regex equivalents like /src/.*/state/ instead of /src//state/). - Default: ["/node_modules/"]. - Use token for project root: e.g., ["//build/", "//dist/"]. - Patterns are applied after testMatch/testRegex finds candidates, filtering them out. - Common pitfalls: confusing regex with globs causes invalid regex errors; paths include full system path, so use leading / for path starts; Windows paths may need escaping. Examples: - Ignore node_modules and build: ["/build/", "/node_modules/"] - Ignore files starting with DISABLED.: "/DISABLED\." - Negative lookahead (exclude specific subpath): "/dist/(?!e2e/sfn)" Official docs confirm: "These pattern strings match against the full path." GitHub issues and Stack Overflow examples validate regex-only behavior and full-path matching.

Citations:


Fix .worktrees Jest ignore regex; current pattern fails to match .worktrees paths.

At Line 2, the pattern '/(^|\\/)\\.worktrees\\//' starts with a literal / followed by (^|\\/), which means the leading / makes the ^ anchor impossible to match, leaving only the \/ branch. This requires a double-slash before .worktrees, so the pattern effectively never matches typical paths like /repo/.worktrees/. Tests under .worktrees/ directories will not be ignored.

Suggested patch
-	testPathIgnorePatterns: ['/e2e/', '/node_modules/', '/(^|\\/)\\.worktrees\\//'],
+	testPathIgnorePatterns: ['/e2e/', '/node_modules/', '(^|[/\\\\])\\.worktrees([/\\\\]|$)'],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
testPathIgnorePatterns: ['/e2e/', '/node_modules/', '/(^|\\/)\\.worktrees\\//'],
testPathIgnorePatterns: ['/e2e/', '/node_modules/', '(^|[/\\\\])\\.worktrees([/\\\\]|$)'],
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@jest.config.js` at line 2, The regex in testPathIgnorePatterns currently has
a leading literal slash which prevents the ^ anchor from matching; update the
pattern in jest.config.js for testPathIgnorePatterns (the entry currently
'/(^|\\/)\\.worktrees\\//') to remove the leading slash so it reads
'(^|\\/)\\.worktrees\\/' (or an equivalent pattern that matches either
start-of-string or a path separator before .worktrees, e.g.,
'^(.*/)?\\.worktrees\\/') so .worktrees paths are correctly ignored.

transformIgnorePatterns: [
'node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg|@rocket.chat/ui-kit)'
],
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
"resolveJsonModule": true
},
"exclude": ["node_modules", "__mocks__"]
"exclude": ["node_modules", "__mocks__", "**/.worktrees/**"]
}
Loading