Skip to content

fix(scripts): make test scripts cross-platform with cross-env#1079

Merged
jSydorowicz21 merged 1 commit into
rcfrom
fix/windows-test-script
Jun 6, 2026
Merged

fix(scripts): make test scripts cross-platform with cross-env#1079
jSydorowicz21 merged 1 commit into
rcfrom
fix/windows-test-script

Conversation

@jSydorowicz21
Copy link
Copy Markdown
Contributor

@jSydorowicz21 jSydorowicz21 commented Jun 6, 2026

@-

Summary by CodeRabbit

  • Chores
    • Updated test scripts to run consistently across different operating systems and environments.
    • Added cross-platform environment variable support to development tooling.

The `test`, `test:watch`, and `test:coverage` scripts used a bare
`NODE_OPTIONS=--max-old-space-size=8192 vitest ...` env-var prefix. That
syntax only works in POSIX shells. On Windows, npm runs scripts through
cmd.exe, which treats `NODE_OPTIONS=...` as a command and fails with
"'NODE_OPTIONS' is not recognized as an internal or external command".

Because the pre-push hook runs `npm run validate:push` -> `npm run test`,
this broke `git push` for every Windows contributor, forcing a
`--no-verify` bypass that skips the entire validation gate (prettier,
type checks, ESLint, tests).

Wrap the three scripts with `cross-env` (added as a devDependency) so the
env var is set portably across Windows, macOS, and Linux. Verified under
cmd.exe: the bare form fails with exit 1, the cross-env form propagates
NODE_OPTIONS correctly and exits 0.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 6, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 13d473d2-3488-4b8b-afcf-60c6d1548bd9

📥 Commits

Reviewing files that changed from the base of the PR and between 15194f7 and d5a7e13.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • package.json

📝 Walkthrough

Walkthrough

This PR updates npm test scripts to use cross-env for cross-platform environment variable handling. The test, test:watch, and test:coverage scripts now prefix their Vitest invocations with cross-env while preserving the existing NODE_OPTIONS memory limit. The cross-env package is added to devDependencies to enable this.

Changes

Test Script Cross-platform Configuration

Layer / File(s) Summary
Cross-env integration
package.json
Test scripts updated to prefix Vitest execution with cross-env while preserving NODE_OPTIONS=--max-old-space-size=8192. The cross-env package added to devDependencies.

🎯 1 (Trivial) | ⏱️ ~2 minutes

🐰 Cross the env with ease so grand,
From Windows wide to Unix land,
Test scripts hop and skip with care,
Memory set, no need to spare!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: making test scripts cross-platform compatible using cross-env tool.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows-test-script

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.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Jun 6, 2026

Greptile Summary

This PR wraps the three main test scripts (test, test:watch, test:coverage) with cross-env so that NODE_OPTIONS=--max-old-space-size=8192 is set correctly on Windows, where the bare VAR=value cmd shell syntax is not supported.

  • Adds cross-env@7.0.3 to devDependencies and updates package-lock.json with the correct integrity hash and resolved cross-spawn ^7.0.1 sub-dependency.
  • Note that several other scripts (dev:prod-data, dev:main, dev:main:prod-data) still use Unix-only VAR=value assignment, though those appear intentionally out of scope for this change (a separate Windows dev script already exists via dev:win).

Confidence Score: 5/5

Safe to merge - the change is a minimal, correct addition of cross-env that makes test scripts functional on Windows without touching any application logic.

The change adds a well-established utility (cross-env 7.0.3) as a dev dependency and applies it only to the three test scripts that previously failed on Windows. The lockfile integrity hash matches the published package, the sub-dependency (cross-spawn) is already present at a compatible version, and no production code or runtime behavior is affected.

No files require special attention.

Important Files Changed

Filename Overview
package.json Adds cross-env prefix to test, test:watch, and test:coverage scripts so that NODE_OPTIONS is set cross-platform (fixes Windows incompatibility with Unix VAR=value syntax).
package-lock.json Adds the cross-env@7.0.3 lockfile entry with correct integrity hash and cross-spawn ^7.0.1 sub-dependency; no hoisting conflicts since cross-spawn 7.0.6 already exists in the lockfile.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[npm run test / test:watch / test:coverage] --> B[cross-env]
    B --> C{Platform?}
    C -->|Windows| D[Sets NODE_OPTIONS via SET command]
    C -->|macOS / Linux| E[Sets NODE_OPTIONS via export]
    D --> F[vitest run / vitest]
    E --> F
    F --> G[8192 MB heap limit applied]
Loading

Reviews (1): Last reviewed commit: "fix(scripts): make test scripts cross-pl..." | Re-trigger Greptile

@jSydorowicz21 jSydorowicz21 merged commit 80e036e into rc Jun 6, 2026
5 checks passed
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