Skip to content

chore: enable jest cache and broaden worktree ignore pattern#7156

Merged
diegolmello merged 1 commit into
developfrom
chore.jest-cache
Apr 14, 2026
Merged

chore: enable jest cache and broaden worktree ignore pattern#7156
diegolmello merged 1 commit into
developfrom
chore.jest-cache

Conversation

@diegolmello

@diegolmello diegolmello commented Apr 14, 2026

Copy link
Copy Markdown
Member

Proposed changes

Speeds up local yarn test runs by enabling a persistent Jest cache and broadens the worktree ignore pattern so tests in any */worktrees/* directory (e.g. .worktrees/, .claude/worktrees/, .omc/worktrees/, .superset/worktrees/) are skipped — not just the root .worktrees/.

Changes:

  • jest.config.js
    • Replace literal .worktrees/ in testPathIgnorePatterns with regex <rootDir>/.*worktrees/ so any parent directory containing a worktrees/ folder is ignored. Anchoring to <rootDir> ensures the pattern does not match when Jest is invoked from inside a worktree (the worktree's own tests still run).
    • Add the same pattern to modulePathIgnorePatterns (previous entry was scoped only to .worktrees/).
    • Add cacheDirectory: '<rootDir>/.jest-cache' to persist Jest's transform cache across runs. Warm runs of ./app/lib/services/voip went from ~56s to ~2s locally.
  • .gitignore
    • Ignore .jest-cache/.

Issue(s)

https://rocketchat.atlassian.net/browse/CORE-2103

How to test or reproduce

  1. Check out the branch.
  2. Run yarn test ./app/lib/services/voip twice.
  3. First run warms the cache; the second should complete in ~1–2 seconds.
  4. Create a worktree under any */worktrees/* path, drop a .test.ts there, and confirm yarn test (from the main checkout) does not pick it up.
  5. From inside such a worktree, run yarn test and confirm that the worktree's own tests still run and its cache is stored at <worktree>/.jest-cache (separate from the main checkout).

Screenshots

N/A

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

The speedup was tracked to a broken local Watchman binary on macOS (missing libfmt.11.dylib after a Homebrew upgrade); however the Jest cache change is beneficial regardless of Watchman state and is safe for CI (actions/cache can optionally be wired up later to persist .jest-cache between CI runs, but is not required for correctness).

Summary by CodeRabbit

  • Chores
    • Updated Jest test runner configuration to streamline development experience with optimized cache management stored locally on disk.
    • Refined directory patterns to improve organization and prevent potential test interference from project worktrees and module directories.
    • Updated project ignore rules to maintain a cleaner development environment.

@coderabbitai

coderabbitai Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Jest configuration and gitignore updates to manage cache directory, ignore worktrees in module and test path patterns, and store Jest cache in a project-local directory.

Changes

Cohort / File(s) Summary
Jest Configuration and Cache Management
.gitignore, jest.config.js
Added .jest-cache/ to gitignore. Updated jest.config.js with cacheDirectory pointing to project-local cache, added modulePathIgnorePatterns to ignore worktree modules, and replaced testPathIgnorePatterns entry with absolute-rooted pattern matching worktrees.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

type: chore

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The pull request title accurately summarizes the main changes: enabling Jest cache and broadening the worktree ignore pattern. It is specific, concise, and directly reflects the primary changes in the changeset.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@diegolmello diegolmello had a problem deploying to experimental_ios_build April 14, 2026 21:55 — with GitHub Actions Failure
@diegolmello diegolmello had a problem deploying to experimental_android_build April 14, 2026 21:55 — with GitHub Actions Failure
@diegolmello diegolmello had a problem deploying to official_android_build April 14, 2026 21:55 — with GitHub Actions Failure
@diegolmello diegolmello changed the title Chore: enable jest cache and broaden worktree ignore pattern chore: enable jest cache and broaden worktree ignore pattern Apr 14, 2026

@OtavioStasiak OtavioStasiak left a comment

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.

LGTM

@diegolmello diegolmello merged commit d95ed13 into develop Apr 14, 2026
6 of 11 checks passed
@diegolmello diegolmello deleted the chore.jest-cache branch April 14, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants