node-reinstall icon indicating copy to clipboard operation
node-reinstall copied to clipboard

Add BATS test suite

Open adamsardo opened this issue 6 months ago • 3 comments

Addresses #49.

This adds a basic bats-core test setup for node-reinstall:

  • make test runs bash -n ./node-reinstall and the BATS suite.
  • The BATS tests run the script with temporary HOME and PREFIX paths.
  • Destructive/external commands (sudo, rm, curl, node, npm, nvm, nave) are shadowed by mocks, so the tests can exercise the reinstall paths without deleting or installing anything.
  • The suite covers help/version/unknown option handling, default NVM install flow, requested version handling, installed-version reuse, Nave mode, and global npm module reinstall.
  • GitHub Actions runs the suite on Ubuntu and macOS.

Verified locally:

make test

Result: 7 BATS tests passing.

If the bounty on #49 is still active, happy to coordinate payout however you prefer after review.

adamsardo avatar May 09 '26 13:05 adamsardo

CI note: the new test workflow has not actually run yet. GitHub shows the pull-request workflow run as action_required with zero jobs, so it likely needs maintainer approval for a first-time/fork workflow run.

Local verification still passes here:

make test

That runs bash -n ./node-reinstall plus 7 BATS tests. The tests shadow sudo, rm, curl, node, npm, nvm, and nave, and use temporary HOME/PREFIX paths so the destructive reinstall paths are exercised without touching the real machine.

adamsardo avatar May 09 '26 13:05 adamsardo

Thanks @adamsardo for putting this together. It's been a while since I worked on this project, but I'll work through this PR today and get back up to speed. Please let me know a PayPal or Venmo address where I can pay the bounty.

brock avatar May 11 '26 16:05 brock

No problem at all @brock! Take your time - PayPal email is: [email protected]

adamsardo avatar May 11 '26 16:05 adamsardo