WEBUI-2038 : Migrate unit tests from Karma to Web Test Runner#3184
Open
madhurkulshrestha-hyland wants to merge 12 commits into
Open
WEBUI-2038 : Migrate unit tests from Karma to Web Test Runner#3184madhurkulshrestha-hyland wants to merge 12 commits into
madhurkulshrestha-hyland wants to merge 12 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates the project’s unit-test harness from Karma (@open-wc/karma-esm) to Web Test Runner while keeping the existing “single barrel entry” approach (test/load-all-tests.js) and preserving broad coverage reporting for Sonar.
Changes:
- Replace Karma config/runtime with
web-test-runner.config.mjsand WTR-basednpm test/npm run test:watch. - Reorganize test helper scripts into
scripts/test/unit/andscripts/test/ftest/, including coverage post-processing (zero-coverage injection). - Update docs/CI guidance to reflect the new unit test runner and the 1-entry-file execution model.
Reviewed changes
Copilot reviewed 27 out of 29 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| web-test-runner.config.mjs | Adds Web Test Runner configuration (single entry file, coverage config, log filtering). |
| test/setup.js | Updates shared Mocha bootstrap for WTR, coverage materialization tweaks, and async-error suppression logic. |
| test/nuxeo-edit-documents-button.test.js | Updates expected i18n warning string. |
| test/nuxeo-dropzone.test.js | Stubs i18n to avoid test failures under the new runner behavior. |
| test/nuxeo-document-create.test.js | Stubs i18n to avoid test failures under the new runner behavior. |
| sonar-project.properties | Updates comments to reference WTR-based coverage. |
| scripts/test/unit/web-test-runner-fallback-plugin.mjs | Adds dev-server fallback responses to reduce noisy 404/invalid JSON during tests. |
| scripts/test/unit/web-test-runner-coverage-flag-plugin.mjs | Injects a browser flag to let test/setup.js detect native V8 coverage runs. |
| scripts/test/unit/print-test-runner-notice.js | Prints a banner explaining why WTR reports “1/1 test files”. |
| scripts/test/unit/inject-zero-coverage.js | Post-processes lcov to add explicit 0%-coverage entries for manifest files missing from the report. |
| scripts/test/unit/generate-test-load-all.js | Generates test/load-all-tests.js barrel used as the single WTR entry point. |
| scripts/test/unit/generate-coverage-imports.js | Generates test/coverage-imports-data.js manifest for coverage materialization. |
| scripts/test/ftest/runner.js | Moves functional test runner script under scripts/test/ftest/. |
| scripts/karma-esm-sequential-test-imports.js | Removes unused Karma workaround script. |
| README.md | Updates unit test description to mention WTR’s 1 entry file with many Mocha tests. |
| package.json | Replaces Karma deps/scripts with WTR deps and new test pipeline scripts. |
| karma.conf.js | Removes Karma configuration. |
| eslint.config.mjs | Updates config-file linting target from karma.conf.js to web-test-runner.config.mjs. |
| CONTRIBUTING.md | Updates test docs and CI description for WTR. |
| ARCHITECTURE.md | Updates tech stack docs for WTR and script layout. |
| AGENTS.md | Updates contributor workflow/testing notes for WTR. |
| .gitignore | Updates comments for generated test barrel/coverage manifest scripts. |
| .github/workflows/test.yaml | Updates workflow comments to reflect WTR-based npm test. |
| .github/skills/write-unit-test/SKILL.md | Updates skill guidance to WTR workflow (regenerate barrel). |
| .github/skills/update-ai-context/SKILL.md | Updates context guidance to reference WTR instead of Karma. |
| .github/instructions/unit-tests.instructions.md | Updates unit-test instructions to WTR + barrel model. |
| .github/instructions/build-config.instructions.md | Updates build-config instructions from Karma to WTR. |
| .github/copilot-instructions.md | Updates repo instructions to reflect WTR unit testing. |
madhurkulshrestha-hyland
added a commit
that referenced
this pull request
May 24, 2026
Fix benign 404 suppression to accept error objects or message strings, rephrase setup.js comment, rename fallbackBody parameter to avoid shadowing path import, and update coverage-imports docs for Web Test Runner. Co-authored-by: Cursor <cursoragent@cursor.com>
madhurkulshrestha-hyland
added a commit
that referenced
this pull request
May 24, 2026
Fix benign 404 suppression to accept error objects or message strings, rephrase setup.js comment, rename fallbackBody parameter to avoid shadowing path import, and update coverage-imports docs for Web Test Runner. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 28 out of 30 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
test/setup.js:180
- The capture-phase
unhandledrejection/errorlisteners stop propagation and preventDefault unconditionally. This can suppress real unhandled errors that occur during a test (not just “after test boundary”), causing tests to pass while errors are silently ignored. Consider only suppressing known-benign failures (e.g. based on_isBenignNuxeoNetworkFailure) or gating suppression to post-test situations so genuine async errors still fail the suite.
window.addEventListener(
'unhandledrejection',
(event) => {
const reason = event.reason;
_logIgnoredAsyncFailure('unhandledrejection', reason);
event.stopImmediatePropagation();
event.preventDefault();
},
true,
);
window.addEventListener(
'error',
(event) => {
_logIgnoredAsyncFailure('error', event.error || event.message);
event.stopImmediatePropagation();
event.preventDefault();
},
true,
Replace @open-wc/karma-esm with @web/test-runner, reorganize test scripts, restore full-tree coverage reporting for Sonar, and fix related test failures. Co-authored-by: Cursor <cursoragent@cursor.com>
The load-all-tests.js graph is slow to transform on CI runners; 30s browserStartTimeout caused false failures before Mocha could start. Co-authored-by: Cursor <cursoragent@cursor.com>
System google-chrome-stable on GitHub runners mismatches puppeteer-core. Pass puppeteer to chromeLauncher and install bundled Chromium in CI. Co-authored-by: Cursor <cursoragent@cursor.com>
npm ci --ignore-scripts skips Puppeteer's browser download, so Sonar and other workflows that run npm test failed to launch Chrome for Web Test Runner. Co-authored-by: Cursor <cursoragent@cursor.com>
Fix benign 404 suppression to accept error objects or message strings, rephrase setup.js comment, rename fallbackBody parameter to avoid shadowing path import, and update coverage-imports docs for Web Test Runner. Co-authored-by: Cursor <cursoragent@cursor.com>
WTR filterBrowserLogs only forwards error-level browser logs in CI, so console.warn import failures were invisible unless WTR_VERBOSE=1. Co-authored-by: Cursor <cursoragent@cursor.com>
Strip WTR query strings before matching setup.js for coverage flag injection, log non-benign stray async failures as console.error, stop filtering those logs in WTR config, and fix ftest runner cucumber report cleanup/spawn args. Co-authored-by: Cursor <cursoragent@cursor.com>
Only suppress stray async errors outside active tests, fail coverage materialization on import errors (Karma parity), and wrap long lines / encode TINY_JPEG as base64 for max-len compliance. Co-authored-by: Cursor <cursoragent@cursor.com>
1d14b2a to
114fbdc
Compare
Add pretest:watch so watch mode installs Puppeteer Chromium, split the TINY_JPEG base64 across short lines, and wrap the coverage manifest expect.fail message for max-len readability. Co-authored-by: Cursor <cursoragent@cursor.com>
Add a Notes column to the README commands table and omit blank lines from zero-coverage lcov DA/LF counts in inject-zero-coverage.js. Co-authored-by: Cursor <cursoragent@cursor.com>
Use dev-server transform hook for coverage flag injection and add empty Notes cells to all README command table rows. Co-authored-by: Cursor <cursoragent@cursor.com>
Document --grep and setup-first entry files; warn that --files on a suite alone skips test/setup.js and breaks globals. Co-authored-by: Cursor <cursoragent@cursor.com>
|
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.



Summary
@open-wc/karma-esm/ Karma with@web/test-runner+ Mocha TDD for unit testsscripts/test/unit/andscripts/test/ftest/Test plan
npm test— 1888 tests pass, coverage generatednpm run lintJIRA: https://hyland.atlassian.net/browse/WEBUI-2038
Made with Cursor