Enabled running both Vitest and Karma tests for packages.#1317
Enabled running both Vitest and Karma tests for packages.#1317martnpaneq merged 17 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the ckeditor5-dev-tests automated test runner to support running Karma and Vitest in the same invocation, which is needed to enable a gradual Karma→Vitest migration across packages.
Changes:
- Refactors
runAutomatedTests()to collect matched test files, detect each package’s runner viapackage.jsonscripts.test, and partition execution between Karma and Vitest. - Adds a Vitest runner that spawns a single
pnpm vitestprocess with--projectflags and blocks--watchfor mixed Karma+Vitest selections. - Adds coverage merging to produce a unified
coverage/lcov.info, plus extensive new unit tests for Vitest-only, mixed runs, and coverage merging.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
packages/ckeditor5-dev-tests/lib/tasks/runautomatedtests.js |
Implements mixed Karma+Vitest orchestration, Vitest spawning, runner partitioning, and coverage merging. |
packages/ckeditor5-dev-tests/tests/tasks/runautomatedtests.js |
Extends unit tests to cover Vitest-only runs, mixed routing, watch restrictions, error aggregation, and coverage merging. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Coverage merging unreachable when any test runner fails
- Moved coverage merging to run before aggregated runner errors are thrown so unified coverage is produced even when tests fail.
Or push these changes by commenting:
@cursor push 02ce42a643
Preview (02ce42a643)
diff --git a/packages/ckeditor5-dev-tests/lib/tasks/runautomatedtests.js b/packages/ckeditor5-dev-tests/lib/tasks/runautomatedtests.js
--- a/packages/ckeditor5-dev-tests/lib/tasks/runautomatedtests.js
+++ b/packages/ckeditor5-dev-tests/lib/tasks/runautomatedtests.js
@@ -69,13 +69,13 @@
}
}
+ if ( options.coverage ) {
+ mergeCoverageReports( karmaFiles.length > 0, vitestProjects.length > 0 );
+ }
+
if ( errors.length ) {
throw aggregateErrors( errors );
}
-
- if ( options.coverage ) {
- mergeCoverageReports( karmaFiles.length > 0, vitestProjects.length > 0 );
- }
}
// -- Glob resolution & file collection -----------------------------------------------------------This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
|
After merging this PR, some changes in
In order to rewrite a single package to Vitest:
import { defineProject } from 'vitest/config';
export default defineProject( {
test: {
name: 'upload', // TODO: Replace with the actual package name.
include: [ 'tests/*' ],
exclude: [ 'tests/manual/*', 'tests/_utils/*' ]
}
} ); |
|
Add a changelog entry, please. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.



🚀 Summary
runAutomatedTeststo support both Karma and Vitest test frameworks simultaneously during the Karma-to-Vitest migrationscripts.testin itspackage.json— if it containsvitest, the package is routed to Vitest; otherwise KarmaVitest packages are run in a singlepnpm vitestprocess using the--projectflag, leveraging the existing workspacevitest.config.mjs-fargumentcoverage/lcov.infowith consistent relative pathsHow it works
Two packages: utils and upload are "mock" migrated to Vitest in
ckeditor5on branchi/4307-test-wrapper-v2.Given
pnpm test -f upload -f utils -f emoji -b ChromeHeadless --coverage:partitionByRunner()reads each package'spackage.jsonand splits files:-
emoji→ Karma (novitestin test script)-
upload,utils→ Vitest ("test": "vitest run")pnpm vitest --run --project upload --project utils📌 Related issues
Test plan
i/4307-test-wrapper-v2branch inckeditor5repository.pnpm test -f upload -f utils -f emoji -b ChromeHeadless --coveragefrom the repository rootpnpm test -f utils -f upload -b ChromeHeadless(no Karma started)pnpm test -f emoji -b ChromeHeadless(no Vitest started)Warning
The integration with coverage report sent to
lcovwas not tested, because it is run only onmasterbranch. Here is the reasoning behind why it should work correctly, without running it.See screenshot
Note
Medium Risk
Moderate risk because it changes the core automated test runner flow (file selection, coverage scoping, process spawning) and could alter CI/local test behavior across packages.
Overview
runAutomatedTests()can now execute Karma and Vitest tests in one invocation. It collects all matching test files, detects each package’s runner via itspackage.jsonscripts.test, partitions the selection, then runs Karma first and Vitest second.Adds a Vitest execution path that spawns
pnpm vitestper detected project (passing--run/--watch, optional coverage tocoverage-vitest, and explicit file paths), restricts watch mode for mixed-runner selections, and aggregates errors when both runners fail. Karma entry generation is adjusted to include only Karma-selected files to avoid instrumenting Vitest packages.Updates/extends
runautomatedtestsunit tests to cover Vitest-only, mixed-runner, multi-project Vitest runs, watch-mode rejection, and failure aggregation, and adds a changelog entry documenting the new behavior.Written by Cursor Bugbot for commit e7e72c1. This will update automatically on new commits. Configure here.