Repository navigation
test: run the test suite on real browsers with Vitest browser mode - #224
Merged
Merged
Conversation
jsdom only approximates how real engines deliver MutationObserver records and run microtask checkpoints, which this library depends on. Run every test file on Chromium, Firefox and WebKit through the Playwright provider instead, and drop jsdom. - Replace node:timers/promises with a local delay helper, since Vite externalizes node:* modules in the browser and the import fails. - Keep the per-test sandbox element: browser mode runs each test file in its own iframe, but the tests in a file still share one document. - Limit pnpm coverage to Chromium, because the v8 provider refuses to start with several browser instances. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The XPath test appended the element before calling waitElement, because jsdom could not exercise dynamic detection, and the FIXME callback in Promise.all was never invoked. Start waiting first, append the element afterwards, and assert that the initial check finds nothing while a later observer-driven check returns the element. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Cache the browser binaries keyed by the Playwright version. The system packages the browsers need are not part of the cache, so install them on every run. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The first run spent about 15s downloading the browsers and about 49s installing their system packages, which the cache cannot hold. A hit would save only the download, at the cost of restoring a 494MB entry that also counts against the repository cache quota. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.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.
Closes #210
Summary
MutationObserverrecords and run microtask checkpoints, which jsdom only approximates.customMatcherXPath test so it actually checks detection of an element added later, which jsdom could not exercise (the old FIXME).AGENTS.md.Background
Findings checked on all three engines with throwaway probe tests:
test-sandboxelement is still needed (#lateis used by several tests insrc/index.test.ts). The comments now give this reason instead of the jsdom issue.node:timers/promises: importing it fails in the browser (Module "node:timers/promises" has been externalized for browser compatibility), so the tests use a localdelayhelper.pnpm coverageruns on Chromium only (--project chromium).Notes
*.test-d.ts) still run and pass, but they now run once per browser instance, sotscruns three times.jsdomis no longer a direct dependency, butpnpm-lock.yamlstill resolves it as the optionaljsdompeer ofvitest, sopnpm installkeeps installing it although no test uses it.pnpm install --fix-lockfileandpnpm update vitest @vitest/*keep the entry; only a lockfile generated from scratch drops it. Regenerating the whole lockfile would move unrelated versions, so it is left as is here; the next Renovate lock file maintenance should drop it.Test plan
pnpm test-cipasses on Chromium, Firefox and WebKit (99 tests, no type errors)describe.shuffle: 5 runs in a row with different seeds, all passingMutationObserverspy tests give the sameobserve/disconnectcounts and order on all three enginespnpm vitest run --coverage --project chromiumproduces a v8 reportbiome ci,typecheckandbuildpass🤖 Generated with Claude Code