test(scripts): run OpenClaw formatter tests without vitest#3063
Conversation
Constraint: Root script tests should run with Node's built-in test runner and avoid app-only devDependencies. Rejected: Add vitest to the repo root | broadens dependency surface for one script test. Confidence: high Scope-risk: narrow Directive: Keep script-only tests executable from the repository root without app workspace packages. Tested: node --test scripts/tools-generator/__tests__/openClaw-formatter.test.js; node scripts/codex-pr-preflight.mjs --lightweight; pnpm typecheck; git diff --check Not-tested: Full format:check/pre-push hook; cargo is not installed in this environment.
📝 WalkthroughWalkthroughThe test file migrates from ChangesVitest to Node Built-in Test Framework Migration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ 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. Comment |
|
Thanks for the checks. I rechecked this PR on current state:
|
|
I reviewed all open PRs from Clarification on
|
sanil-23
left a comment
There was a problem hiding this comment.
@alexzhu0 the code looks good — clean, focused fix for a real problem (vitest not available at the repo root). the local expect compat wrapper is the right call: it covers exactly the matchers the existing tests use, and node:assert/strict gives proper strict-equal semantics for toBe.
one thing to note: Rust Core Coverage is failing in CI, but this PR only touches a JS script test with zero Rust changes, so that failure looks pre-existing rather than caused by this change. if you can confirm it was already failing on main, i'll come back and approve once the CI picture is clear. let me know if you need help tracking it down.
sanil-23
left a comment
There was a problem hiding this comment.
@alexzhu0 quick CI update — the checks have now completed after your upstream merge:
- Rust Core Coverage: failing on
connectivity_raw_coverage_e2eandtools_channels_raw_coverage_e2e. These are Rust integration tests with no connection to your JS-only change. Both were already red before this PR and are pre-existing failures in the codebase. - E2E Playwright lane 1/4: one of four shards failed. The other three passed. This looks like an infra flake given the sharded setup and the fact that the other three lanes are green.
The code itself remains clean — no issues introduced by this PR. Once the pre-existing Rust coverage failures are resolved (or confirmed as OK to ignore by the team) and CI is fully green, I'll come back and approve.
Summary
vitestimport with Node's built-innode:testrunner.expectcompatibility helper so the existing assertions stay unchanged.Problem
scripts/tools-generator/__tests__/openClaw-formatter.test.jsimports fromvitest.vitestis installed under the app workspace, not the repository root where this script test lives.ERR_MODULE_NOT_FOUNDbefore the formatter assertions can execute.Solution
node:testandnode:assert/strict, matching the no-dependency pattern used by other root script tests.Submission Checklist
Impact
Related
AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
Commit & Branch
codex/OH-2611-tools-generator-node-testdfe5fafValidation Run
pnpm --filter openhuman-app format:check(blocked after app Prettier passed; see below)pnpm typechecknode --test scripts/tools-generator/__tests__/openClaw-formatter.test.jsnode scripts/codex-pr-preflight.mjs --lightweightgit diff --checkValidation Blocked
command:env COREPACK_HOME=/Users/alex/PR/.corepack PNPM_HOME=/Users/alex/PR/.pnpm-home pnpm --filter openhuman-app format:checkerror:sh: cargo: command not foundimpact:The app Prettier phase passed, but Rust formatting and the pre-push hook cannot complete in this local environment until Cargo is installed.Behavior Changes
Parity Contract
Duplicate / Superseded PR Handling