Skip to content

test: speed up staged CLI tests#35

Merged
chenjiahan merged 1 commit into
mainfrom
chenjiahan/optimize-staged-tests
Jul 12, 2026
Merged

test: speed up staged CLI tests#35
chenjiahan merged 1 commit into
mainfrom
chenjiahan/optimize-staged-tests

Conversation

@chenjiahan

Copy link
Copy Markdown
Member

Summary

The staged CLI tests dominated the suite because each option recreated a Git repository and ran lint-staged in a new process. This PR mocks lint-staged and verifies forwarded options directly while retaining lightweight help and invalid-option CLI coverage. Rstest now extends the Rslib adapter so source tests inherit RSTACK_VERSION from source.define.

Performance

Measured locally on macOS with Node.js v24.12.0 and warm dependencies:

Command Before After Improvement
pnpm --filter rstack test test/cli/staged/index.test.ts 6.16s 0.70s ~89% faster
node --run test 6.78s 1.49s ~78% faster

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a2d8824c-23cd-42ac-984e-376af4876758

📥 Commits

Reviewing files that changed from the base of the PR and between ad63bb0 and b35b15d.

📒 Files selected for processing (2)
  • packages/rstack/rstack.config.ts
  • packages/rstack/test/cli/staged/index.test.ts

📝 Walkthrough

Walkthrough

The test configuration callback is now asynchronous and extends its returned configuration with withRslibConfig(). Staged CLI tests now mock configuration loading and lint-staged execution instead of using temporary git repositories. The suite verifies default options and mappings for long-form, short, and aliased CLI flags.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly captures the main change: speeding up staged CLI tests.
Description check ✅ Passed The description is directly related to the test refactor and config change in this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chenjiahan/optimize-staged-tests

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.

@chenjiahan chenjiahan merged commit e586d17 into main Jul 12, 2026
4 checks passed
@chenjiahan chenjiahan deleted the chenjiahan/optimize-staged-tests branch July 12, 2026 05:20
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