Convert test suite from Karma/Chai/Mocha to Vitest with Playwright#48
Merged
Convert test suite from Karma/Chai/Mocha to Vitest with Playwright#48
Conversation
- Removed karma, chai, mocha, chromium dependencies - Installed vitest@^3.2.4, @vitest/browser, and playwright - Created vitest.config.js with browser mode using chromium headless - Updated test file to use vitest imports and assertions - Renamed test.js to test.spec.js for vitest discovery - Removed karma.config.js and pretest build script - Updated package.json test script to use vitest - Updated .eslintrc.json to remove mocha environment and globals - Updated GitHub workflows to use Node 24 by default with Node 22 matrix - Added playwright install chromium step to CI workflows Co-authored-by: dgreif <3026298+dgreif@users.noreply.github.com>
- Converted all test callbacks from done() to promises for Vitest compatibility - Updated .eslintrc.json to disable filename convention for test files - Removed executablePath from vitest config as per requirements - All tests pass with vitest and lint is clean Co-authored-by: dgreif <3026298+dgreif@users.noreply.github.com>
- Use simpler browser config format as recommended - Remove instances array wrapper - Config now uses browser.name directly with chromium Co-authored-by: dgreif <3026298+dgreif@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Convert test framework to Vitest with Playwright integration
Convert test suite from Karma/Chai/Mocha to Vitest with Playwright
Oct 7, 2025
- Add test/__screenshots__ to .gitignore - Remove Node version matrix, use only Node 24 - Use wildcard test/*.js in lint script Co-authored-by: dgreif <3026298+dgreif@users.noreply.github.com>
Contributor
Author
Added test/screenshots to .gitignore in commit 6b4e2cf. |
There was a problem hiding this comment.
Pull Request Overview
This PR modernizes the test infrastructure by migrating from the legacy Karma/Chai/Mocha testing stack to Vitest with browser mode and Playwright. The change simplifies the testing setup, eliminates build dependencies for tests, and aligns with modern JavaScript testing practices.
Key changes:
- Replaced Karma/Chai/Mocha with Vitest and Playwright for browser testing
- Updated test files to use Vitest's API and import from TypeScript source files directly
- Modified CI workflows to use Node 24 and install Playwright browsers
Reviewed Changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.js | New Vitest configuration replacing karma.config.js with browser mode and middleware |
| test/test.spec.js | New test file with Vitest API and promise-based assertions |
| test/test.js | Removed original Karma/Mocha test file |
| package.json | Updated dependencies and scripts for Vitest |
| .github/workflows/publish.yml | Updated to Node 24 with Playwright installation |
| .github/workflows/nodejs.yml | Updated to Node 24 with Playwright installation |
| .eslintrc.json | Removed Mocha-specific configuration and globals |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR modernizes the test infrastructure by replacing Karma, Chai, and Mocha with Vitest in browser mode using Playwright. This change simplifies the testing setup, eliminates the need for a separate build step before testing (since Vitest can run TypeScript directly), and aligns with modern JavaScript testing practices.
Changes
Test Infrastructure
karma,karma-chai,karma-chrome-launcher,karma-mocha,karma-mocha-reporter,mocha,chai,chromiumvitest@^3.2.4,@vitest/browser,playwrightassertAPI to Vitest'sexpectAPIConfiguration
Created
vitest.config.jsto replacetest/karma.config.js:Test Files
test/test.js→test/test.spec.js(follows vitest naming conventions)describe,it,beforeEach,afterEach,expect../src/index.ts) instead of built dist filesassert.ok()→expect().toBe(true)/expect().toBeTruthy()assert.equal()→expect().toBe()assert.deepEqual()→expect().toEqual()assert.instanceOf()→expect().toBeInstanceOf()assert.isNull()→expect().toBeNull()assert.isFalse()→expect().toBe(false)assert.match()→expect().toMatch()done()callbacks to promises (required by Vitest)Build Scripts
Updated
package.json:pretestscript - no longer needed since Vitest runs TypeScript directlytestscript fromkarma start test/karma.config.jstovitest runlintscript to use wildcardtest/*.jsfor better flexibilityLinting
Updated
.eslintrc.json:mocha: trueenvironment settingassertandremoteFormglobals (no longer needed)CI/CD Workflows
Updated GitHub Actions workflows:
npx playwright install chromiumstepnpx playwright install chromiumstepactions/checkout@v4andactions/setup-node@v4Git Configuration
test/__screenshots__to.gitignoreto exclude Vitest browser mode screenshot artifactsTesting
All 9 tests pass successfully:
Linting and builds also pass without errors.
Running Tests Locally
To run tests locally, Playwright browsers must be installed first:
npx playwright install chromium npm testThe CI workflows automatically install the necessary browsers before running tests.
Original prompt
💡 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.