Skip to content

test: migrate from jest to vitest - #1808

Merged
madhavilosetty-intel merged 1 commit into
mainfrom
test/migrate-jest-to-vitest
Aug 27, 2026
Merged

test: migrate from jest to vitest#1808
madhavilosetty-intel merged 1 commit into
mainfrom
test/migrate-jest-to-vitest

Conversation

@madhavilosetty-intel

@madhavilosetty-intel madhavilosetty-intel commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Replaces jest/ts-jest with vitest 4 + @vitest/coverage-v8.
All 326 tests pass, verified per-suite against the jest baseline rather than on the total alone.
The built dist is byte-identical to HEAD, so no shipped code changes.

Coverage baseline note

The reported coverage total drops versus the jest-era number. Jest had no collectCoverageFrom, so it only instrumented files the tests actually loaded; vitest's v8 provider counts every file matched by coverage.include (src/core/**), including files no test imports (e.g. Desktop.ts at 0%). This is a one-time denominator change — the same code is tested as before, per-suite coverage was verified against the jest baseline, and no code regressed. The memory-hungry RLEDecoder/ImageHelper suites stay excluded from the coverage run (as under jest), with their targets excluded from the denominator.

PR Checklist

  • Unit Tests have been added for new changes
  • API tests have been updated if applicable
  • All commented code has been removed
  • If you've added a dependency, you've ensured license is compatible with Apache 2.0 and clearly outlined the added dependency.

What are you changing?

Anything the reviewer should know when reviewing this PR?

If the there are associated PRs in other repositories, please link them here (i.e. device-management-toolkit/repo#365 )

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the project’s test runner from Jest/ts-jest to Vitest (with v8 coverage), updating configuration, CI, and the existing unit tests to run under the new framework without changing shipped runtime output.

Changes:

  • Adds Vitest configuration + setup (jsdom env, single-fork execution, v8 coverage, junit output).
  • Updates TypeScript config and the test suite to use Vitest globals / vi mocks instead of Jest APIs.
  • Updates CI/workflow and tooling config (npm scripts, eslint ignores) and removes Jest config.

Reviewed changes

Copilot reviewed 22 out of 25 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vitest.setup.ts Adds jsdom canvas getContext stub to avoid native canvas dependency.
vitest.config.ts Defines Vitest include patterns, jsdom env, reporters, and v8 coverage config.
tsconfig.json Enables Vitest globals typing and adjusts TS compiler options for the new test setup.
tsconfig.build.json Updates build exclusions for the new Vitest setup file.
src/test/zlib.spec.js Migrates Jest mock usage to vi and switches module import style for Vitest.
src/test/serverinit.spec.ts Removes Jest done callback pattern; uses assertion counting instead.
src/test/securityresponse.spec.ts Removes Jest done callback pattern; uses assertion counting instead.
src/test/securityoptions.spec.ts Removes Jest done callback pattern; uses assertion counting instead.
src/test/rledecoder.spec.ts Updates environment annotation and replaces Jest mocks with vi mocks.
src/test/kvmui.test.ws.ts Adjusts config typing and WebSocket constructor typing for Vitest/TS.
src/test/keyboardhelper.test.ts Migrates spies/mocks to Vitest (vi) and updates spy typing.
src/test/keyboardhelper.spec.ts Updates environment annotation and replaces Jest spy utilities with Vitest equivalents.
src/test/imagehelper.spec.ts Updates environment annotation and replaces Jest mocks with vi mocks.
src/test/iderDataProcessor.spec.ts Migrates spies/mocks to Vitest and updates spy typing.
src/test/handshakestate.spec.ts Removes Jest done callback pattern; uses assertion counting instead.
src/test/framebufferbellservercuttext.spec.ts Removes Jest done callback pattern; uses assertion counting instead.
src/test/encoding.spec.ts Removes Jest done callback pattern; uses assertion counting instead.
src/test/amtredirector.spec.ts Replaces Jest mocks with vi mocks.
src/test/amtider.spec.ts Replaces Jest mocks/spies with Vitest equivalents; updates mock typings.
src/test/amtdesktop.spec.ts Replaces Jest mocks/spies with Vitest equivalents.
package.json Swaps Jest scripts/deps for Vitest + coverage-v8; adds typecheck.
jest.config.js Removes Jest configuration file.
eslint.config.cjs Ignores generated dist/** and coverage/**.
.github/workflows/node.js.yml Updates CI to run typecheck, Vitest test/coverage, and renames artifact step.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/test/iderDataProcessor.spec.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 25 changed files in this pull request and generated 3 comments.

Suppressed comments (1)

vitest.setup.ts:41

  • The mocked canvas context currently hard-codes ctx.canvas to a plain object, so ctx.canvas !== the actual HTMLCanvasElement and width/height mutations don't affect the element. Returning the real canvas element ("this") makes code like ImageHelper.setRotation behave closer to production.
  canvas: {
    height: 768,
    width: 1366
  }
}) as unknown as HTMLCanvasElement['getContext']

Comment thread vitest.setup.ts Outdated
Comment thread vitest.config.ts Outdated
Comment thread tsconfig.build.json
@madhavilosetty-intel
madhavilosetty-intel force-pushed the test/migrate-jest-to-vitest branch from 1bf4222 to d5338f7 Compare August 27, 2026 22:58
Replaces jest/ts-jest with vitest 4 + @vitest/coverage-v8.
All 326 tests pass, verified per-suite against the jest baseline rather
than on the total alone. The built dist is byte-identical to HEAD, so no
shipped code changes.
@madhavilosetty-intel
madhavilosetty-intel force-pushed the test/migrate-jest-to-vitest branch from d5338f7 to 40edbb7 Compare August 27, 2026 23:01
@madhavilosetty-intel
madhavilosetty-intel merged commit 94563e3 into main Aug 27, 2026
6 checks passed
@madhavilosetty-intel
madhavilosetty-intel deleted the test/migrate-jest-to-vitest branch August 27, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants