Repository navigation
Conversation
✅ Deploy Preview for chartjs-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Size Change: 0 B Total Size: 363 kB ℹ️ View Unchanged
|
kurkle
force-pushed
the
migrate-tests-to-vitest-p2-fixtures-under-vitest
branch
from
November 24, 2026 15:06
7fff527 to
4557286
Compare
This was referenced Nov 24, 2026
The CommonJS fixtures do not load under Vitest yet.
Load the CommonJS fixtures through a Vite transform in test/vitest.shared.js, and stub jasmine.fixture.specs in test/index.js so that each fixture has one runner. Add `pnpm run fixtures:update`, which writes missing or changed reference images from Chromium. Pre-bundle moment: otherwise the date adapter used its own copy and formatted dates in the machine's time zone instead of Etc/UTC. Rename the grace-10% fixture, whose name Vite cannot serve, and call the triggerMouseEvent global in the four fixtures that used Jasmine's.
`-t scale.time` also runs scale.timeseries. Show the slash that selects one directory and the `$` that selects one fixture.
Jasmine warned three times per placeholder that it had no expectations.
The design assumed only the blending mattered; the fix goes to chartjs-test-utils.
Regenerate doughnut-circumference-over-2pi from Chromium. Raise the tolerance of single-slice-opacity and min-max-skip/no-collision from 0.001 to 0.0012: they differ only in Firefox, where they measure just over 0.1%, and their Chromium render already matches.
1.1.1 rejected the OffscreenCanvasRenderingContext2D of a chart drawn on an OffscreenCanvas, so controller.line/point-style-offscreen-canvas failed before any comparison. 1.1.2 accepts it, and the fixture passes against its existing reference image in Chromium and Firefox.
kurkle
force-pushed
the
migrate-tests-to-vitest-p2-fixtures-under-vitest
branch
from
November 25, 2026 14:58
be237e8 to
0be7e99
Compare
kurkle
marked this pull request as ready for review
November 25, 2026 15:10
Member
Author
|
@etimberg the karma coverage will be red for these till all is converted, acceptable? |
Member
yup, all good |
etimberg
approved these changes
Nov 25, 2026
This was referenced Nov 25, 2026
This was referenced Nov 26, 2026
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.
Piece P2 of the
migrate-tests-to-vitestdesign (openspec/changes/migrate-tests-to-vitest/, tasks section 2).What was missing
The 667 image fixtures ran only under Karma, from a
describe('auto', jasmine.fixture.specs('<dir>'))line in each of 25 spec files. Vitest could not load them: every.jsfixture is CommonJS, and Vite serves source files as ES modules.test/fixtures/scale.timeserieshad no line of its own; it ran only because the line forscale.timematched its path by prefix.What changed
test/specs/fixtures.spec.jsglobs every fixture config and PNG and registers onedescribeper top-level fixture directory, usingcreateFixturesfromchartjs-test-utils1.x. A new fixture or directory runs without a spec line, andscale.timeseriesgets its own group.test/vitest.shared.jsexportscommonjsFixtures(), a Vite plugin that wraps eachtest/fixtures/**/*.jscontainingmodule.exportsas an ES module with a default export. Fixtures stay CommonJS, including those in open pull requests.vitest.config.jsuses the plugin.test/index.js:jasmine.fixture.specsis now a stub. Each remainingdescribe('auto', ...)line in a Karma spec registers one placeholder (runs under Vitest (test/specs/fixtures.spec.js)), so each fixture has exactly one runner.pnpm run fixtures:update [-t <dir or fixture>]setsUPDATE_FIXTURES=1. The config then registers thesaveFixtureImagecommand (createSaveFixtureImage()fromchartjs-test-utils/node) and runs Chromium only. It writes only PNGs that are missing or differ, and prints each file it writes. A normal run writes nothing:git statusafter the full run below showed no PNG.optimizeDeps.include):moment-timezone's pre-bundle carried its own copy of moment, and the excludedchartjs-adapter-momentimported the rawmomentpackage.Etc/UTC. On a UTC+2 machine,scale.time/labels-datewas shifted two hours (4.61% different).test/specs/vitest.setup.spec.jspins this: the adapter formats in the default zone of moment-timezone. It sets the zone toEtc/GMT-5, so it fails on any machine, including CI's UTC clock, where no fixture would notice.triggerMouseEventglobal instead ofjasmine.triggerMouseEvent:controller.doughnut/event-replay.jscore.interaction/drawActiveElementsOnTop-false.jscore.interaction/nearest-partial-bar.jscore.interaction/nearest-point-behind-scale.jsscale.linear/grace/grace-10%.{js,png}→grace-10-percent.{js,png}(image unchanged). Vite puts the%raw into the import URL, and its server rejects the request ("Malformed URI sequence in request URL"), so the whole fixture spec failed to load. Vite 8.3.8, the latest release, still does this.test/.eslintrc.ymldeclarestriggerMouseEventforfixtures/**/*.js. Without it the four fixtures above failno-undef. This file is outside the design's file list for this piece; the design did not anticipate the lint rule.test/setup.jslinks the library issue behind its registration workaround: Chart.register() registers nothing from an ES module namespace object #12437docs/developers/contributing.mdhas the new image-test recipe (fixtures:update, then look at the PNG), filtering fixtures with-t, and what"debug": truedoes now: the test always fails and logs the actual, expected and diff images to the browser console.design.mdrecords the rename, the lint override, the moment fix, the pixelmatch 8 decision and the OffscreenCanvas fix inchartjs-test-utils1.1.2. Every box of section 2 is ticked intasks.md.Failing first
vitest run --browser.headless --project chromium test/specs/fixtures.spec.jswith only the spec added (first commit):With that pair excluded, the CommonJS form still stopped the whole file:
The new setup test without the moment pre-bundle, on a UTC+2 machine:
Counts
.js, 140.json), each with its PNG./base/test/fixtures/<path>.js; Vitest names them<path>.Image results
The verdict on the images comes from this pull request's CI run on Ubuntu. The local results below come from macOS 26.6 and are for comparison only. On that machine Karma itself fails some fixtures on
master.Karma on
master, locally:scale.radialLinear/ticks-below-zeroscale.timeseries/data-timestampsscale.time/ticks-roundplugin.filler/line/drawTimeFillFalse/beforeDatasetDrawplugin.filler/line/drawTimeFillFalse/beforeDrawplugin.filler/line/drawTimeFillFalse/beforeDatasetsDrawplugin.filler/line/above-below-vertical-linechartVitest on this branch, locally, before the three fixture updates below (Chromium 10 failures, Firefox 11):
spriteText)controller.doughnut/doughnut-circumference-over-2picontroller.doughnut/single-slice-opacitycontroller.line/point-style-offscreen-canvasplugin.filler/line/above-below-vertical-linechartplugin.filler/line/drawTimeFillFalse/beforeDatasetDrawplugin.filler/line/drawTimeFillFalse/beforeDatasetsDrawplugin.filler/line/drawTimeFillFalse/beforeDrawscale.linear/min-max-skip/no-collisionscale.radialLinear/ticks-below-zeroscale.time/labels-stringsscale.time/ticks-roundscale.timeseries/data-timestampsOn Ubuntu CI, three fixtures failed. Karma passes them, and the cause is the comparer, not the rendering.
chartjs-test-utils1.x compares with pixelmatch 8, which measures colour difference in OKLab where pixelmatch 5 (Karma's) used YIQ, so a fixture'sthresholdnow admits a different difference. On the same Vitest render, pixelmatch 5 finds 0 differing pixels indoughnut-circumference-over-2piand pixelmatch 8 finds 1306. Source and built bundle render that config identically, and headed browsers give the same result.Pixelmatch 8 stays, and the references are updated where needed:
controller.doughnut/doughnut-circumference-over-2pipnpm run fixtures:update. The new image differs from the old one only in the border where the 400° arc starts and overlaps itself.controller.doughnut/single-slice-opacitytolerance0.001 (default) → 0.0012 (limit 78). Its Chromium render already matches, so regenerating writes nothing.scale.linear/min-max-skip/no-collisiontolerance0.001 (default) → 0.0012 (limit 48). Same reason.All three now pass locally in Chromium and Firefox. The other local failures above also fail under local Karma, or are text-bearing local noise; CI on Ubuntu does not show them.
OffscreenCanvas fixture
controller.line/point-style-offscreen-canvasfailed in both browsers with "Input value is not a valid image source.":chartjs-test-utils1.1.1 accepted only aCanvasRenderingContext2Din its image matcher, and a chart drawn on anOffscreenCanvashas anOffscreenCanvasRenderingContext2D. This pull request takeschartjs-test-utils^1.1.2 (chartjs/chartjs-test-utils#45), which accepts it; the fixture now passes against its existing reference image in Chromium and Firefox. Thechartjs-test-utils-karmaalias stays on 0.4.Try it