Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 10, 2025

Migration from Karma/Chai/Mocha to Vitest with Playwright - COMPLETED ✅

Summary:

Successfully migrated the test infrastructure from Karma/Chai/Mocha to Vitest with Playwright browser mode. All requirements have been met and verified.

Changes Completed:

  • Installed Vitest version ^3.2.4 and Playwright
  • Created vitest.config.ts with chromium browser in headless mode (no executablePath specified)
  • Updated test/test.js to use Vitest imports (describe, it, beforeAll, expect)
  • Converted all assertions from Chai to Vitest (assert.equal → expect().toBe(), etc.)
  • Removed pretest build script (vitest runs TypeScript directly)
  • Updated package.json test script to "vitest run"
  • Removed all karma/mocha/chai dependencies
  • Removed karma.config.js
  • Created test/.eslintrc.json with vitest-specific eslint rules
  • Updated GitHub workflows to Node 24 with node-version-file and latest actions/setup-node@v4 and actions/checkout@v4
  • Added npx playwright install chromium --only-shell step in CI workflows
  • Added build and lint steps to publish workflow
  • Updated .gitignore with test/screenshots
  • Updated .node-version to 24
  • Upgraded TypeScript to v5.9.3 for compatibility
  • Updated tsconfig.json with skipLibCheck for type compatibility
  • Removed undici-types dependency (not needed with skipLibCheck)

Verification:

✅ All 14 tests passing
✅ Lint passing (no errors)
✅ Build passing
✅ No references to karma/mocha/chai remain in source files

Original prompt

This package currently uses Karma, chai and mocha to run tests within a browser. Convert it to use Vitest in browser mode with Playwright. 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.

For the vitest config, only use chromium. Don't specify executablePath, assume it's installed correctly. Also always use headless mode.

Also update all github workflows to run with Node 24. 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 --only-shell.

Update the gitignore with test/__screenshots__ to ignore vitest images.

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 10, 2025 12:21
Co-authored-by: dgreif <3026298+dgreif@users.noreply.github.com>
Co-authored-by: dgreif <3026298+dgreif@users.noreply.github.com>
Copilot AI changed the title [WIP] Convert testing framework to Vitest with Playwright Convert test infrastructure from Karma/Mocha/Chai to Vitest with Playwright Oct 10, 2025
Copilot AI requested a review from dgreif October 10, 2025 12:29
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
node-version: 24
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot revert to using node-version-file in the CI workflows. Then update .node-version contents to 24

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit above. Both workflows now use node-version-file: '.node-version' and .node-version contains 24.

package.json Outdated
Comment on lines 32 to 40
"overrides": [
{
"files": [
"test/**/*.js"
],
"rules": {
"import/named": "off"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot Move this into test/.eslintrc.json

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit above. Created test/.eslintrc.json with the import/named rule override and removed the overrides section from package.json.

… remove undici-types

Co-authored-by: dgreif <3026298+dgreif@users.noreply.github.com>
Co-authored-by: dgreif <3026298+dgreif@users.noreply.github.com>
@dgreif dgreif marked this pull request as ready for review October 10, 2025 23:24
@dgreif dgreif requested a review from a team as a code owner October 10, 2025 23:24
Copilot AI review requested due to automatic review settings October 10, 2025 23:24
Copy link

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 successfully migrates the test infrastructure from Karma/Chai/Mocha to Vitest with Playwright browser mode, upgrading to Node 24 and modernizing the CI/CD workflows.

  • Replaced Karma/Chai/Mocha testing stack with Vitest ^3.2.4 and Playwright
  • Updated all test assertions from Chai syntax to Vitest expect() syntax
  • Modernized GitHub workflows to use Node 24 and latest actions

Reviewed Changes

Copilot reviewed 8 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vitest.config.ts New Vitest configuration with Playwright chromium browser support
test/test.js Converted test imports and assertions from Mocha/Chai to Vitest
test/.eslintrc.json Updated ESLint config to remove Mocha globals and add Vitest rules
package.json Replaced Karma/Chai/Mocha dependencies with Vitest and Playwright
karma.config.js Removed obsolete Karma configuration file
.node-version Updated Node version from 22 to 24
.github/workflows/publish.yml Added Playwright installation and build/lint steps
.github/workflows/nodejs.yml Added Playwright installation and lint step
Comments suppressed due to low confidence (1)

test/test.js:1

  • Similar to the previous test, this Promise resolves on the first change event from any checkbox. If multiple checkboxes exist, this could lead to race conditions or incomplete test verification.
import {describe, it, beforeAll, expect} from 'vitest'

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

@dgreif dgreif merged commit eec6da9 into main Oct 13, 2025
4 checks passed
@dgreif dgreif deleted the copilot/convert-to-vitest-playwright branch October 13, 2025 11:44
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