Skip to content

refactor(project): remove support for jest#6452

Merged
joshblack merged 10 commits into
mainfrom
refactor/remove-jest
Aug 4, 2025
Merged

refactor(project): remove support for jest#6452
joshblack merged 10 commits into
mainfrom
refactor/remove-jest

Conversation

@joshblack
Copy link
Copy Markdown
Member

@joshblack joshblack commented Aug 4, 2025

Closes https://github.com/github/primer/issues/5336

Removes Jest from the project in favor of Vitest now that our migration is complete 🫡

Changelog

New

Changed

  • Update vitest to be the default test runner
  • Update references to Jest to instead point to Vitest

Removed

  • Remove support for Jest from the project
  • Remove vitest migration from our migration tracking workflow

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Aug 4, 2025

⚠️ No Changeset found

Latest commit: 4d6a499

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Aug 4, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 4, 2025

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 4, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 90.12 KB (0%)
packages/react/dist/browser.umd.js 90.43 KB (0%)

@joshblack joshblack added the skip changeset This change does not need a changelog label Aug 4, 2025
@github-actions github-actions Bot requested a deployment to storybook-preview-6452 August 4, 2025 21:12 Abandoned
@github-actions github-actions Bot temporarily deployed to storybook-preview-6452 August 4, 2025 21:22 Inactive
@joshblack joshblack marked this pull request as ready for review August 4, 2025 21:31
Copilot AI review requested due to automatic review settings August 4, 2025 21:31
@joshblack joshblack requested a review from a team as a code owner August 4, 2025 21:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 completes the migration from Jest to Vitest as the default test runner for the Primer React project. The key changes focus on removing Jest-specific dependencies, configuration files, and updating test files to use Vitest APIs.

  • Remove Jest configuration files and dependencies
  • Update test files to use Vitest imports and APIs instead of Jest
  • Clean up migration tracking workflow and scripts
  • Update documentation to reference Vitest instead of Jest

Reviewed Changes

Copilot reviewed 23 out of 26 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/ToggleSwitch/__snapshots__/ToggleSwitch.test.tsx.snap Remove Jest snapshot file (entire file deleted)
script/vitest-migration-status.mts Remove migration tracking script (entire file deleted)
packages/react/vitest.config.browser.mts Simplify test inclusion patterns and add exclusions
packages/react/src/utils/testing.tsx Remove Jest-specific testing utilities (entire file deleted)
packages/react/src/utils/test-matchers.tsx Remove Jest-specific test matchers (entire file deleted)
packages/react/src/utils/test-helpers.tsx Add TypeScript suppression comment
packages/react/src/utils/test-deprecations.tsx Remove Jest-specific deprecation handling (entire file deleted)
packages/react/src/experimental/UnderlinePanels/UnderlinePanels.test.tsx Update to use Vitest imports and mock functions
packages/react/src/__tests__/BaseStyles.test.tsx Add type assertions for style expectations
packages/react/src/Overlay/Overlay.test.tsx Fix style assertion value types
packages/react/src/Dialog/Dialog.test.tsx Remove Jest-specific matchmedia mock setup
packages/react/src/DataTable/__tests__/DataTable.test.tsx Add type assertion for style expectation
packages/react/src/ActionList/ActionList.test.tsx Remove axe accessibility test and unused imports
packages/react/package.json Remove Jest-related dependencies
packages/react/jest.config.js Remove Jest configuration file (entire file deleted)
packages/postcss-preset-primer/package.json Remove Babel and Jest dependencies
packages/postcss-preset-primer/config/transform/jsTransform.js Remove Babel Jest transformer (entire file deleted)
package.json Update root package.json to use Vitest commands and remove Jest dependencies
eslint.config.mjs Remove Jest ESLint plugin configuration
contributor-docs/testing.md Update documentation to reference Vitest instead of Jest
contributor-docs/CONTRIBUTING.md Update technology stack reference from Jest to Vitest
.github/workflows/migration-status.yml Remove Vitest migration tracking workflow
.github/workflows/ci.yml Update CI workflow to use single test command

// @ts-nocheck
import {TextEncoder} from 'node:util'

// JSDOM doesn't mock ResizeObserver
Copy link

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

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

The @ts-nocheck directive suppresses all TypeScript checking for this file. This is generally discouraged as it bypasses type safety. Consider either fixing the TypeScript issues or using more specific suppressions like @ts-expect-error or @ts-ignore for individual problematic lines.

Suggested change
// JSDOM doesn't mock ResizeObserver
import {TextEncoder} from 'node:util'
// JSDOM doesn't mock ResizeObserver
// @ts-expect-error: ResizeObserver is not defined in Node.js global types

Copilot uses AI. Check for mistakes.

it('throws an error when the number of tabs does not match the number of panels', () => {
const spy = jest.spyOn(console, 'error').mockImplementation()
const spy = vi.spyOn(console, 'error').mockImplementation(() => {})
Copy link

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

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

The mock implementation for console.error should use a named function or store the original implementation to restore it properly. Consider using mockImplementation(vi.fn()) or storing the original function for better test isolation.

Suggested change
const spy = vi.spyOn(console, 'error').mockImplementation(() => {})
const spy = vi.spyOn(console, 'error').mockImplementation(vi.fn())

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@jonrohan jonrohan left a comment

Choose a reason for hiding this comment

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

Heck yea!

@joshblack joshblack added this pull request to the merge queue Aug 4, 2025
Merged via the queue into main with commit 52fff13 Aug 4, 2025
43 checks passed
@joshblack joshblack deleted the refactor/remove-jest branch August 4, 2025 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm skip changeset This change does not need a changelog staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants