- Notifications
You must be signed in to change notification settings - Fork17
Convert from Karma/Chai/Mocha to Vitest with Playwright browser mode#41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
Co-authored-by: dgreif <3026298+dgreif@users.noreply.github.com>
.github/workflows/nodejs.yml Outdated
strategy: | ||
matrix: | ||
node-version:[22, 24] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@copilot remove this matrix. Just use 24.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Removed the matrix. Now using Node 24 only. Fixed in 67e5336
test/.eslintrc.json Outdated
"globals": { | ||
"assert":true | ||
"describe":"readonly", | ||
"it":"readonly", | ||
"expect":"readonly" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@copilot we shouldn't need these since we import from the vitest package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Removed the globals since they're imported from vitest. Fixed in 67e5336
test/setup.js Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@copilot this file duplicates a lot of what is in test-runner.js. Remove test-runner.js and update the tests to simply call a function which starts up the socket server inbeforeAll
and shuts it down inafterAll
. Update the package.json to simply runvitest run
instead of test-runner.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Removed test-runner.js and test/setup.js. Created a simpler shell script (scripts/test-with-server.sh) that starts the WebSocket server in the background and runs vitest. Updated package.json to runvitest run
via this script. Fixed in 67e5336
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@copilot Ok, I now see that we need to run the websocket server in Node, not in the browser. I like the bash file you created, but please move the server JS portion of it intotest/websocket-server.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Moved the WebSocket server code into test/websocket-server.js. The bash script now simply starts that file as a background process. Fixed in 22af8f3
vitest.config.ts Outdated
}, | ||
], | ||
}, | ||
include:['test/**/test.js'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@copilot look fortest/test*.js
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Changed pattern totest/test*.js
. Fixed in 67e5336
Co-authored-by: dgreif <3026298+dgreif@users.noreply.github.com>
Co-authored-by: dgreif <3026298+dgreif@users.noreply.github.com>
There was a problem hiding this 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 converts the test setup from Karma/Chai/Mocha to Vitest with Playwright browser mode, streamlining the testing infrastructure while maintaining all existing test functionality.
Key changes:
- Migrated to Vitest ^3.2.4 with Playwright browser mode using Chromium headless
- Updated test assertions from Chai to Vitest's expect API
- Simplified test execution by removing the pretest build step and using direct TypeScript imports
- Updated CI workflows to use Node 24 and include Playwright installation
Reviewed Changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 9 comments.
Show a summary per file
File | Description |
---|---|
vitest.config.ts | New Vitest configuration with Playwright browser mode and Chromium setup |
test/websocket-server.js | Extracted WebSocket server code from karma config for standalone test server |
test/test.js | Updated test file with Vitest imports and expect assertions replacing Chai |
test/.eslintrc.json | Removed Mocha environment and globals, added module source type |
scripts/test-with-server.sh | New script to manage WebSocket server lifecycle during testing |
package.json | Removed Karma/Chai/Mocha dependencies, added Vitest and Playwright, updated test script |
karma.config.cjs | Removed Karma configuration file |
.github/workflows/publish.yml | Updated to Node 24 and added Playwright installation |
.github/workflows/nodejs.yml | Updated to Node 24 and added Playwright installation |
Tip: Customize your code reviews with copilot-instructions.md.Create the file orlearn how to get started.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Plan: Convert from Karma/Chai/Mocha to Vitest with Playwright
All tasks completed successfully. Tests are passing with vitest in browser mode using Playwright chromium.
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Clickhere to start the survey.