Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 7, 2025

This PR modernizes the testing infrastructure by migrating from Mocha/Chai to Vitest v3.2.4, and updates GitHub Actions workflows to use the latest Node.js versions.

Test Framework Migration

Removed dependencies:

  • mocha, chai, chai-spies, ts-node and related @types packages

Added:

  • vitest@^3.2.4 with proper TypeScript support

Test files updated:
All test files (test/index.ts, test/decorator.ts) have been converted from Chai assertions to Vitest:

// Before (Chai)
import chai from 'chai'
import spies from 'chai-spies'
const {expect, spy} = chai
const fn = spy(incr(1))
expect([result]).to.eql([1, 1, 1, 1])
expect(fn).to.have.been.called.exactly(1)

// After (Vitest)
import {describe, it, expect, vi} from 'vitest'
const fn = vi.fn(incr(1))
expect([result]).toEqual([1, 1, 1, 1])
expect(fn).toHaveBeenCalledTimes(1)

Configuration changes:

  • Created vitest.config.ts for Vitest configuration
  • Updated test script from node --loader ts-node/esm.mjs node_modules/mocha/lib/cli/cli.js to vitest run
  • Removed mocha configuration section from package.json
  • Vitest runs TypeScript directly without needing a separate build step

Dependency Updates

  • Updated typescript from ^4.6.4 to ^5.9.3 for better compatibility
  • Updated @types/node from ^14.0.19 to ^22.18.8 to match Node.js 24 requirements
  • Added skipLibCheck: true to tsconfig.json to handle type definitions in node_modules

GitHub Actions Workflows

nodejs.yml:

  • Updated to use Node.js 24

publish.yml:

  • Updated default Node.js version from 22 to 24

Both workflows already used the latest versions of actions/checkout@v4 and actions/setup-node@v4.

Validation

All existing tests pass successfully:

  • ✅ 11 tests across 2 test files
  • ✅ Lint passes without errors
  • ✅ Build completes successfully (ESM + CJS outputs)
  • ✅ No breaking changes to the public API
Original prompt

This package currently uses chai and mocha to run tests. Convert it to use Vitest. Install vitest version ^3.2.4. Update test files to import describe/it/etc from vitest and use assertion helpers from vitest. Remove the pretest build script since vitest can run TypeScript directly. Run the tests with npm test and verify they pass. Remove all references to karma/chai/mocha.

Also update all github workflows to run with Node 24 by default, and include Node 22 in matrix runs (only if matrix is already configured, don't add it). Drop older versions. Update actions to use the latest version of actions/setup-node and actions/checkout. Add a step before running tests in CI which runs npx playwright install chromium.

Ensure lint and tests both pass. Remove any references to karma/mocha/chai from the lint config.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Update testing framework to use Vitest and remove deprecated packages Convert test framework from Mocha/Chai to Vitest and update CI workflows Oct 7, 2025
@Copilot Copilot AI requested a review from dgreif October 7, 2025 20:28
Copilot finished work on behalf of dgreif October 7, 2025 20:28
@Copilot Copilot AI requested a review from dgreif October 8, 2025 02:31
Copilot finished work on behalf of dgreif October 8, 2025 02:31
@dgreif dgreif marked this pull request as ready for review October 8, 2025 02:31
@dgreif dgreif requested a review from a team as a code owner October 8, 2025 02:31
@Copilot Copilot AI review requested due to automatic review settings October 8, 2025 02:31
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the testing infrastructure from Mocha/Chai to Vitest v3.2.4 and updates CI workflows to use Node.js 24.

  • Replaces Mocha/Chai test framework with Vitest for modern TypeScript testing
  • Updates Node.js version to 24 in GitHub Actions workflows
  • Removes outdated dependencies and configurations while adding Playwright support

Reviewed Changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
vitest.config.ts Adds Vitest configuration for TypeScript test execution
test/index.ts Converts Chai assertions to Vitest syntax and spy functions
test/decorator.ts Updates test assertions from Chai to Vitest format
package.json Removes Mocha/Chai dependencies, adds Vitest, updates TypeScript and Node types
.github/workflows/publish.yml Updates Node.js to v24 and adds Playwright installation
.github/workflows/nodejs.yml Updates Node.js to v24 and adds Playwright installation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

with:
node-version: 22
node-version: 24
- run: npx playwright install chromium
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot we actually don't need playwright since we aren't using browser mode. Remove all installs in ci

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed playwright install steps from both nodejs.yml and publish.yml workflows. (commit: will be included in next push)

@Copilot Copilot AI requested a review from dgreif October 9, 2025 02:40
Copilot finished work on behalf of dgreif October 9, 2025 02:40
Copy link

@bteng22 bteng22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

@dgreif dgreif merged commit 90c456a into main Oct 9, 2025
4 checks passed
@dgreif dgreif deleted the copilot/convert-tests-to-vitest branch October 9, 2025 14:30
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.

3 participants