-
Notifications
You must be signed in to change notification settings - Fork 17
Convert tests from mocha/chai to Vitest with Playwright browser mode #28
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… Node 22/24 Co-authored-by: dgreif <[email protected]>
Co-authored-by: dgreif <[email protected]>
dgreif
left a comment
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 add test/__screenshots__ to the gitignore
vitest.config.ts
Outdated
| launch: { | ||
| executablePath: '/usr/bin/chromium' | ||
| } |
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 and instead run npx playwright install chromium before the tests in CI
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 executablePath configuration and added npx playwright install chromium step to both CI workflows (node.js.yml and publish.yml) in commit 2fb8a93
…l in CI Co-authored-by: dgreif <[email protected]>
Added Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
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 migrates the test framework from Mocha/Chai to Vitest with Playwright browser mode, updating to modern testing infrastructure and Node.js versions.
- Converts all test files from Mocha/Chai syntax to Vitest equivalents
- Configures Vitest to run tests in real Chromium browser via Playwright
- Updates CI workflows to Node 22.x/24.x and installs Playwright browsers
Reviewed Changes
Copilot reviewed 5 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | New Vitest configuration enabling browser mode with Playwright |
| test/index.ts | Migrated test imports and assertions from Mocha/Chai to Vitest |
| package.json | Updated dependencies and test script for Vitest |
| .github/workflows/publish.yml | Updated to Node 24 and added Playwright install step |
| .github/workflows/node.js.yml | Updated matrix to Node 22.x/24.x and added Playwright install step |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
bteng22
left a comment
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.
🚀
This PR migrates the test suite from mocha/chai to Vitest with Playwright browser mode, modernizes the CI/CD pipeline to use Node 22 and 24, and updates dependencies.
Motivation
The project was using mocha and chai for browser-based testing, which required additional build steps and dependencies. Vitest provides a modern, fast testing framework with built-in TypeScript support and browser testing capabilities through Playwright.
Changes
Test Framework Migration
Migrated all 22 tests from mocha/chai to Vitest:
import {describe, it, beforeEach} from 'mocha'withimport {describe, it, beforeEach, expect} from 'vitest'expect(calls).to.eql([...])→expect(calls).toEqual([...])expect(calls).to.have.lengthOf(1)→expect(calls).toHaveLength(1)package.jsonfrommocha -r ts-node/register --extension tstovitest runBrowser Testing Configuration
Created
vitest.config.tswith Playwright provider to run tests in a real browser environment:Playwright browsers are installed in CI via
npx playwright install chromiumstep added before running tests.Dependencies
Added:
vitest@^3.2.4- Modern test framework with built-in TypeScript support@vitest/browser- Browser testing support for Vitestplaywright- Browser automation for running tests@types/node&@types/debug- Type definitions for Node.js and debug modulesRemoved:
mocha,@types/mocha- Replaced by Vitestchai,@types/chai- Vitest has built-in assertionsts-node- No longer needed as Vitest handles TypeScript directlyUpdated:
typescriptfrom v4.1.5 to v5.9.3 - Required for Vitest type compatibilityCI/CD Updates
Updated GitHub Actions workflows to use modern Node.js versions and install Playwright browsers:
npx playwright install chromiumstepnpx playwright install chromiumstepactions/checkout@v4andactions/setup-node@v4TypeScript Configuration
Updated
tsconfig.json:skipLibCheck: trueto handle third-party library type definitionsGitignore
Added
test/__screenshots__to.gitignoreto exclude Vitest browser mode screenshot artifacts from version control.Testing
All 22 tests pass successfully:
Build and lint both pass without errors or warnings.
Breaking Changes
None. This is purely an internal testing infrastructure change with no impact on the public API or package consumers.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.