Skip to content

test: run the bubble, polarArea and radar controller specs under Vitest - #12498

Merged
kurkle merged 1 commit into
chartjs:masterfrom
kurkle:migrate-tests-to-vitest-p5-convert-controllers
Nov 25, 2026
Merged

kurkle merged 1 commit into
chartjs:masterfrom
kurkle:migrate-tests-to-vitest-p5-convert-controllers

Conversation

@kurkle

@kurkle kurkle commented Nov 25, 2026

Copy link
Copy Markdown
Member

Piece P5 of openspec/changes/migrate-tests-to-vitest. It follows #12436 (Vitest beside Karma) and #12444 (fixtures under Vitest).

What was missing

controller.bubble, controller.polarArea and controller.radar still ran under Karma/Jasmine. No open pull request touches these three spec files.

What changed

Each file is renamed with git mv from *.tests.js to *.spec.js, so git follows the rename (81-91% similarity), and the idioms are converted with the table in design D5:

Jasmine Vitest Uses
describe('auto', jasmine.fixture.specs(...)) deleted; fixtures.spec.js already runs these directories 3
spyOn(o, 'draw') vi.spyOn(o, 'draw').mockImplementation(() => {}) 17
.calls.count() .mock.calls.length 17
jasmine.objectContaining expect.objectContaining 9
jasmine.triggerMouseEvent( triggerMouseEvent( 30
this.chart in the Interactions hooks and tests let chart in that describe 3 per file
expect(x).withContext(i) expect(x, `${i}`) 24

toEqual stays toEqual. No imports are added.

Numeric contexts become template strings. In each case the context is a loop index that starts at 0. Vitest drops a falsy message, so expect(x, 0) would lose the context that Jasmine's withContext(0) shows. I checked this with a probe spec in Chromium:

  • expect(10, 3).toBeCloseToPixel(20) fails with 3: Expected 10 to be close to pixel 20.
  • expect({a: 1}, 2).toEqual(expect.objectContaining({a: 5})) fails with 2: expected { a: 1 } to deeply equal ....
  • expect(1, 0).toBe(2) fails with only expected 1 to be 2 // Object.is equality. The 0 is gone.

expect(x, `${i}`) keeps the context for every index. Only failure messages differ, never which tests pass.

openspec/changes/migrate-tests-to-vitest/tasks.md: section 5 is ticked.

Counts

Local runs on macOS, full suite of each runner, per browser:

Chrome / Chromium Firefox
Karma before 1180 (1155 tests + 25 fixture placeholders) 1180 (1155 + 25)
Karma after 1132 (1110 tests + 22 fixture placeholders) 1132 (1110 + 22)
Vitest before 682 682
Vitest after 727 727
  • Without placeholders, Karma falls by 45 tests per browser and Vitest rises by 45. Those 45 tests are 18 in bubble, 14 in polarArea and 13 in radar.
  • The 3 fixture placeholders went with the deleted jasmine.fixture.specs lines.
  • Running Karma with --grep on each file before the change gave 19, 15 and 14 per browser: the 45 tests plus the 3 placeholders.
  • Vitest shows the same 15 local image failures before and after: 8 fixtures in Chromium and 7 in Firefox under plugin.filler/line, scale.time, scale.timeseries and scale.radialLinear/ticks-below-zero. These are known macOS rendering differences; CI on Ubuntu is the judge. All 90 runs of the converted specs pass (45 tests in each of the two browsers).

How to try it

pnpm exec vitest run --browser.headless test/specs/controller.bubble.spec.js test/specs/controller.polarArea.spec.js test/specs/controller.radar.spec.js
pnpm exec karma start ./karma.conf.cjs --single-run --browsers chrome,firefox

Rename controller.{bubble,polarArea,radar}.tests.js to *.spec.js and
convert the Jasmine idioms with the table in the migrate-tests-to-vitest
design (D5). The fixture lines go, since fixtures.spec.js runs those
directories already.

A numeric withContext(i) becomes expect(x, `${i}`): Vitest drops a falsy
message, so expect(x, 0) would lose the context of the first element.
@github-actions

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 363 kB

ℹ️ View Unchanged
Filename Size
dist/chart.cjs 81.9 kB
dist/chart.js 82.2 kB
dist/chart.umd.js 72.4 kB
dist/chart.umd.min.js 72.4 kB
dist/chunks/helpers.dataset.cjs 25.8 kB
dist/chunks/helpers.dataset.js 25.6 kB
dist/helpers.cjs 1.52 kB
dist/helpers.js 1.33 kB

compressed-size-action

@netlify

netlify Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for chartjs-docs canceled.

Name Link
🔨 Latest commit 4b6a6dd
🔍 Latest deploy log https://app.netlify.com/projects/chartjs-docs/deploys/6b0701145c15c8fba3aec8dd

@kurkle
kurkle marked this pull request as ready for review November 25, 2026 15:44
@kurkle
kurkle merged commit 44a2430 into chartjs:master Nov 25, 2026
8 checks passed
@kurkle
kurkle deleted the migrate-tests-to-vitest-p5-convert-controllers branch November 25, 2026 16:29
@kurkle kurkle added this to the Version 4.6.3 milestone Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants