Repository navigation
Open
Labels
flag: nice to haveNot on the critical path right nowpriority: lowLow prioritystatus flag: discussNeeds input from various peoplestatus: triageHas not been triaged by admintype: testingRelated to code testingworkload: weeksLikely takes weeks to resolve
Description
Context
Since #478, CI runs no tests at all. The test scripts were removed from all packages without test files, because Web Test Runner (WTR) 0.19 exits with "Could not find any test files", which failed the turbo test task, and with it the Test job of every PR. Turbo now skips every package, so the Test (Node 22/24) jobs install Playwright, build and then test nothing.
Current state of the test setup:
- Tooling in place:
@web/test-runner0.19,@open-wc/testing,@web/test-runner-playwright(Chromium, Firefox, WebKit),@web/dev-server-esbuild,sinon,playwright1.56. There is a shared root config (web-test.runner-config.mjs, with per-file groups) and an older, mostly commented-outweb-test-runner.config.mjsin each package. - Tests: none on
dev.teshas two test files, but both are empty, andtesandro-crateare private with onlydepricated-*scripts. Open PR feat: add surface, font and dark mode controls #446 adds the first real tests:ecc-utils-design/src/global.test.ts(15 theming tests) andecc-client-ga4gh-wes/src/theming.test.ts(4 tests), runs them through the shared config, and fixes that config so Lit's decorators compile. They pass in Chromium, Firefox and WebKit, and they caught a Firefox-only bug, which shows the value of real multi-browser testing. - Build: Lit (2.x in most packages) web components built with tsup/esbuild (
scripts/build.js), Tailwind, and React wrappers via@lit/react. Data access goes through provider interfaces (e.g.WesProvider, withRestWesProviderdoing thefetchcalls), which gives a natural seam for mocking. - Docs app: Next.js 14 + Nextra (
apps/documentation), with live previews of the cloud-registry, design, service-registry, trs, trs-filer and wes components. - No coverage reporting, see also feat(ci): calculate and report test coverage #245. The broader goals in feat: testing #119 (fast tests, UI tests for
ecc-utils-design, test strategies for the service packages) are still open, as is tests: Add tests for new, untested features #366.
Goals
- Unit tests per package: components rendered in a real browser with mocked providers; providers and helpers tested on their own.
- Integration tests: components together with the real
Rest*Provideragainst a mocked GA4GH API (e.g. MSW, or a mock server generated from the OpenAPI specs), covering requests, errors, pagination and events. - End-to-end tests in a browser, through the docs app or a test page per package, against a mock (or containerized real) GA4GH service.
- Coverage reporting to Codecov (as used elsewhere in the org), with a threshold that ratchets up as packages get tests.
- One CI job per level (e.g.
test,integration,e2e), all feeding theCI passedgate, so the ruleset doesn't change.
Recommendation: keep WTR + @open-wc/testing, add Playwright Test for e2e
- Unit and integration: keep WTR with
@open-wc/testing(Mocha + Chai +fixture) and the Playwright launchers, all from the shared root config.- This is what Open WC recommends for Lit libraries, and the dependencies, the configs and feat: add surface, font and dark mode controls #446's tests already use it, so nothing has to be migrated.
- It tests in real Chromium, Firefox and WebKit, which matters for web components (shadow DOM,
:host-context(), adopted stylesheets); feat: add surface, font and dark mode controls #446's Firefox bug would not show up in jsdom or Chromium alone. - Integration tests can run MSW's browser worker (or
sinonfetch stubs) inside the same runner, so the separate job is just a different file pattern (e.g.*.integration.test.ts) or WTR group. - Coverage:
wtr --coverage(V8, Chromium only) writes lcov, which Codecov takes per package as flags.
- End-to-end:
@playwright/test(already a dependency throughplaywright) against the built docs app (next build && next start) or plain per-package test pages, with a mock GA4GH API.- This is the same e2e tool as in cloud-registry-ui, so the org uses one e2e stack.
Downsides: WTR is less actively maintained than Vitest, and its coverage covers Chromium only. If it stalls, the migration later is mostly mechanical (see the Vitest option below).
Alternatives
Option Unit/integ. Browsers Migration Org fit Notes
--------------------------- -------------- ------------ ---------- --------------- ------------------------------
A. WTR + @open-wc/testing real browser Cr, Fx, WK none Open WC default recommended; slower ecosystem
+ Playwright Test (e2e) pace, coverage Chromium only
B. Vitest browser mode real browser Cr, Fx, WK small = CR-UI fast, watch mode, V8/istanbul
(Playwright provider) (provider) (#446) (Vitest 4) coverage, mocking built in;
+ Playwright Test (e2e) Lit decorator config needed
C. Vitest + jsdom/happy-dom simulated DOM none small = CR-UI fastest, but misses shadow DOM
and CSS bugs (e.g. #446's)
D. Storybook + test runner real browser via PW large none also gives a component gallery,
/ interaction tests overlaps with the docs app
E. Playwright component real browser Cr, Fx, WK medium partial experimental, aimed at React/
testing (@playwright/ct) Vue/Svelte, no Lit adapter
- B. Vitest browser mode is the strongest alternative: one runner for unit, integration and coverage, the same as cloud-registry-ui (Vitest 4 + V8 coverage + Playwright for e2e), better DX, and active maintenance. Costs: moving feat: add surface, font and dark mode controls #446's tests (Chai's
expectand@open-wc/testing-helpers'fixturework in Vitest, so this is mostly config), configuring esbuild for Lit's decorators, and replacing the WTR groups and ports. - C is fast but can't see the browser-specific behavior these components depend on; at most as an extra for pure logic (providers, helpers).
- D and E add a large new tool (D) or depend on an experimental feature without Lit support (E) for little gain over A or B.
Migration path
- Land feat: add surface, font and dark mode controls #446 (or its test-runner commits): it fixes the shared config and adds the design and WES tests, with
testscripts that use the shared config on fixed ports. - Unify the config: all packages use
web-test.runner-config.mjs(or the Vitest config for B); remove the per-packageweb-test-runner.config.mjsfiles; give each package a fixed port or let the runner choose free ports. - Re-add
testscripts per package together with its first tests (as test: drop test scripts of packages without tests #478 intends), so turbo never runs a package without tests. One sub-issue per package: design, wes, trs, trs-filer, drs, drs-filer, service-registry, cloud-registry. tesandro-crate: they are private withdepricated-*scripts, and thetestest files are empty. Delete the empty files, and decide whether these packages get tests now or once they are revived.- Integration layer: add MSW (or a mock server from the GA4GH OpenAPI specs) with shared fixtures per API, and a
CIjobintegration. - E2E layer: Playwright Test against the docs app or test pages, as job
e2e, uploading the report as an artifact. - Coverage: upload lcov per package to Codecov (flags per package), start with a threshold for the packages that have tests, and raise it as packages are covered; this closes feat(ci): calculate and report test coverage #245.
- Close feat: testing #119 and tests: Add tests for new, untested features #366 once the setup is in place, or fold them into the sub-issues.
Open questions for Anurag
- Runner: stay with WTR + @open-wc/testing (A), or switch to Vitest browser mode (B) to match cloud-registry-ui?
- E2E target: the docs app (one target, tests what users see, but couples tests to Next.js/Nextra), or minimal test pages per package (faster, isolated)?
- Mock API: MSW handlers written by hand, a mock server generated from the GA4GH OpenAPI specs (e.g. Prism), or real services in containers for e2e (e.g. cloud-registry, as cloud-registry-ui does)?
- Browsers in CI: all three engines on every PR, or Chromium on PRs and all three on
dev(and both Node versions, or one)? - Coverage target: which threshold, and per package or overall?
tesandro-crate: test them now or leave them until they are maintained again?
@anuragxxd, could you make the call on the approach? Once you've decided, we'll split this into sub-issues per package/level.
Metadata
Metadata
Assignees
Labels
flag: nice to haveNot on the critical path right nowpriority: lowLow prioritystatus flag: discussNeeds input from various peoplestatus: triageHas not been triaged by admintype: testingRelated to code testingworkload: weeksLikely takes weeks to resolve
Type
Projects
- StatusShow more project fieldsNice to have
Activity