Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
Copilot wants to merge5 commits intomain
base:main
Choose a base branch
Loading
fromcopilot/convert-to-vitest-playwright

Conversation

Copilot
Copy link

@CopilotCopilotAI commentedOct 7, 2025
edited
Loading

Plan: Convert from Karma/Chai/Mocha to Vitest with Playwright

  • Install vitest ^3.2.4, @vitest/browser, and playwright dependencies
  • Create vitest.config.ts with browser mode configuration using chromium headless
  • Update test/test.js to import describe/it/expect from vitest
  • Update test/.eslintrc.json to remove mocha environment (removed globals as imports are used)
  • Update package.json scripts: remove pretest, update test script to use vitest
  • Remove karma/chai/mocha dependencies from package.json
  • Delete karma.config.cjs
  • Create test script to manage WebSocket server lifecycle (scripts/test-with-server.sh)
  • Extract WebSocket server code to test/websocket-server.js
  • Update GitHub workflows to use Node 24 only (removed matrix)
  • Run lint and tests to verify everything passes (all 20 tests passing)
  • Update vitest config pattern to test/test*.js

All tasks completed successfully. Tests are passing with vitest in browser mode using Playwright chromium.

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 thepretest build script since vitest can run TypeScript directly. Run the tests withnpm test and verify they pass. Remove all references to karma/chai/mocha.

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

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 ofactions/setup-node andactions/checkout. Add a step before running tests in CI which runsnpx 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! Clickhere to start the survey.

Co-authored-by: dgreif <3026298+dgreif@users.noreply.github.com>
@CopilotCopilotAI changed the title[WIP] Refactor testing framework to use Vitest with PlaywrightConvert from Karma/Chai/Mocha to Vitest with Playwright browser modeOct 7, 2025
@CopilotCopilotAI requested a review fromdgreifOctober 7, 2025 20:56
Copilot finished work on behalf ofdgreifOctober 7, 2025 20:56
Comment on lines 8 to 10
strategy:
matrix:
node-version:[22, 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 remove this matrix. Just use 24.

Copy link
Author

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

Comment on lines 10 to 14
"globals": {
"assert":true
"describe":"readonly",
"it":"readonly",
"expect":"readonly"
},
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 shouldn't need these since we import from the vitest package

Copy link
Author

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
Copy link
Contributor

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

Copy link
Author

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

Copy link
Contributor

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

Copy link
Author

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

},
],
},
include:['test/**/test.js'],
Copy link
Contributor

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

Copy link
Author

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>
@CopilotCopilotAI requested a review fromdgreifOctober 8, 2025 00:15
Copilot finished work on behalf ofdgreifOctober 8, 2025 00:15
Co-authored-by: dgreif <3026298+dgreif@users.noreply.github.com>
Copilot finished work on behalf ofdgreifOctober 8, 2025 01:54
@dgreifdgreif marked this pull request as ready for reviewOctober 8, 2025 02:08
@dgreifdgreif requested a review froma team as acode ownerOctober 8, 2025 02:08
@CopilotCopilotAI review requested due to automatic review settingsOctober 8, 2025 02:08
Copy link

@CopilotCopilotAI 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 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
FileDescription
vitest.config.tsNew Vitest configuration with Playwright browser mode and Chromium setup
test/websocket-server.jsExtracted WebSocket server code from karma config for standalone test server
test/test.jsUpdated test file with Vitest imports and expect assertions replacing Chai
test/.eslintrc.jsonRemoved Mocha environment and globals, added module source type
scripts/test-with-server.shNew script to manage WebSocket server lifecycle during testing
package.jsonRemoved Karma/Chai/Mocha dependencies, added Vitest and Playwright, updated test script
karma.config.cjsRemoved Karma configuration file
.github/workflows/publish.ymlUpdated to Node 24 and added Playwright installation
.github/workflows/nodejs.ymlUpdated to Node 24 and added Playwright installation

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

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@dgreifdgreifAwaiting requested review from dgreif

At least 1 approving review is required to merge this pull request.

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Copilot@dgreif

[8]ページ先頭

©2009-2025 Movatter.jp