Skip to content

refactor: migrate to Node.js native test runner and fix runtime bugs#6

Merged
Garbee merged 13 commits intomainfrom
claude/convert-to-native-node-test-runner
Feb 14, 2026
Merged

refactor: migrate to Node.js native test runner and fix runtime bugs#6
Garbee merged 13 commits intomainfrom
claude/convert-to-native-node-test-runner

Conversation

@Claude
Copy link
Contributor

@Claude Claude AI commented Feb 14, 2026

Migrates from Vitest to Node.js native test runner, simplifies build system, and fixes critical post-action bugs causing CI failures.

Testing Framework Migration

  • Node.js native test runner (node:test) replaces Vitest
    • Timer mocking with mock.timers.enable() - tests run in ~400ms vs 21+ seconds
    • Module mocking via mock.module() for systeminformation
    • Updated assertions to node:assert/strict
// Tests now use mocked timers instead of real delays
before(async () => {
  mock.timers.enable({ apis: ['setTimeout', 'Date'] });
  ({ Metrics } = await import("./metrics.ts"));
});

await mock.timers.tick(5000);  // Instant time advancement

Package Management & Build

  • npm replaces pnpm - removed pnpm-lock.yaml, updated all workflows
  • Simplified build - removed source maps, prettier integration, wrapper files
  • Dependencies cleaned - removed 20+ unused devDeps (textlint, vitest, prettier)
  • Action entry points - direct bundle files (dist/main/index.bundle.js)

Bug Fixes

Port race condition (6f43b75)

  • get-port allocated different ports per process → ECONNREFUSED
  • Fixed to port 7777 in src/lib.ts

AbortError in post action (3cddd03)

  • Used promise-based setTimeout from node:timers/promises instead of callback-based
  • Caused uncaught AbortError on clearTimerController.abort()
// Before: promise-based setTimeout with signal
const timer = setTimeout(10 * 1000, () => controller.abort(), { signal });
clearTimerController.abort();  // Throws AbortError

// After: callback-based setTimeout
import { setTimeout as setTimeoutCallback } from "node:timers";
const timer = setTimeoutCallback(() => controller.abort(), 10 * 1000);
clearTimeout(timer);  // Proper cleanup

Configuration

  • .node-version: 24.13.024
  • action.yml: updated branding, author, entry points
  • Removed: vitest.config.ts, eslint.config.mjs, unused build scripts
  • Added: .github/workflows/copilot-setup-steps.yml

Breaking Changes

None - external API unchanged.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh pr view claude/convert-to-native-node-test-REDACTED --json title,body,number /home/REDACTED/.nvm/install.sh /home/REDACTED/.nvm/nvm-exec /home/REDACTED/.nvm/nvm.sh /home/REDACTED/.nvm/package.json /home/REDACTED/.nvm/rename_test.sh /home/REDACTED/.nvm/test /hom�� (http block)

If you need me to access, download, or install something from one of these locations, you can either:

- Remove Vitest dependencies (@vitest/ui, vitest)
- Remove vitest.config.ts
- Add Sinon for mocking (though not used due to ES module limitations)
- Update all test files to use node:test and node:assert/strict
- Update test script to use tsx --test
- Update CLAUDE.md with new test patterns
- Tests now use real systeminformation calls instead of mocks

Co-authored-by: Garbee <868301+Garbee@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] Convert to the native node test runner with mocking Convert tests from Vitest to Node.js native test runner Feb 14, 2026
@Claude Claude AI requested a review from Garbee February 14, 2026 02:38
…cks flag

Co-authored-by: Garbee <868301+Garbee@users.noreply.github.com>
@Claude Claude AI changed the title Convert tests from Vitest to Node.js native test runner Convert tests from Vitest to Node.js native test runner with experimental module mocking Feb 14, 2026
Co-authored-by: Garbee <868301+Garbee@users.noreply.github.com>
@Claude Claude AI changed the title Convert tests from Vitest to Node.js native test runner with experimental module mocking Fix hanging Metrics test by adding stop() cleanup method Feb 14, 2026
Co-authored-by: Garbee <868301+Garbee@users.noreply.github.com>
@Claude Claude AI changed the title Fix hanging Metrics test by adding stop() cleanup method Add Node.js timer mocking to speed up tests from 21s to 400ms Feb 14, 2026
The main action was trying to spawn server.ts instead of server.bundle.js,
causing the server to fail to start in CI. This resulted in ECONNREFUSED
errors when the post action tried to fetch metrics.

Changed server.ts to server.bundle.js in the spawn call so it correctly
references the bundled JavaScript file.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@Claude Claude AI changed the title Add Node.js timer mocking to speed up tests from 21s to 400ms Fix server spawn to use bundled file instead of TypeScript source Feb 14, 2026
Co-authored-by: Garbee <868301+Garbee@users.noreply.github.com>
@Claude Claude AI changed the title Fix server spawn to use bundled file instead of TypeScript source Fix server port to use fixed 7777 instead of dynamic allocation Feb 14, 2026
Co-authored-by: Garbee <868301+Garbee@users.noreply.github.com>
@Claude Claude AI changed the title Fix server port to use fixed 7777 instead of dynamic allocation Fix AbortError in post action from incorrect setTimeout API usage Feb 14, 2026
@Claude Claude AI changed the title Fix AbortError in post action from incorrect setTimeout API usage refactor: migrate to Node.js native test runner and fix runtime bugs Feb 14, 2026
@Garbee Garbee marked this pull request as ready for review February 14, 2026 10:27
@Garbee Garbee merged commit 3526ad2 into main Feb 14, 2026
9 checks passed
@Garbee Garbee deleted the claude/convert-to-native-node-test-runner branch February 14, 2026 19:24
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.

2 participants