Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 7, 2025

Migrated the test suite from Jest (via tsdx) to Vitest, aligning with React 19 testing best practices and modern tooling.

Changes

packages/formik

  • Added Vitest dependencies: vitest, @vitest/ui, @vitest/coverage-v8, jsdom, @testing-library/jest-dom
  • Created vitest.config.ts with jsdom environment, globals enabled, and coverage configuration
  • Updated test/setupTests.ts to import from vitest and filter React act() warnings
  • Replaced Jest APIs throughout test files:
    • jest.fn()vi.fn()
    • jest.spyOn()vi.spyOn()
    • jest.Mockvi.Mock
    • fdescribedescribe
  • Updated test scripts: test, test:watch, test:ui, test:coverage
  • Removed Jest configuration from package.json

packages/formik-native

  • Added Vitest with minimal configuration

Root

  • Removed @types/jest dependency
  • Updated CONTRIBUTING.md references from Jest to Vitest

Before/After

- "test": "tsdx test --env=jsdom"
+ "test": "vitest run"
+ "test:coverage": "vitest run --coverage"
- import { render } from '@testing-library/react';
+ import { vi } from 'vitest';
+ import { render } from '@testing-library/react';

- const validate = jest.fn();
+ const validate = vi.fn();

Results

  • 227 tests passing (226 formik + 1 formik-native)
  • 88.36% coverage maintained
  • ~4-5s test execution with Turbo caching support
Original prompt

Look at the current test suite. And react 19 testing best practices. can update it to vitest


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@changeset-bot
Copy link

changeset-bot bot commented Nov 7, 2025

⚠️ No Changeset found

Latest commit: 7e9dd8f

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

@vercel
Copy link

vercel bot commented Nov 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
formik-docs Error Error Nov 7, 2025 5:22pm

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 7, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Co-authored-by: jaredpalmer <[email protected]>
Copilot AI changed the title [WIP] Update test suite to use vitest framework Migrate test suite from Jest to Vitest Nov 7, 2025
Copilot AI requested a review from jaredpalmer November 7, 2025 17:23
Copy link

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 migrates the Formik project from Jest to Vitest as the testing framework. The migration includes updating test scripts, configuration files, dependencies, and converting all Jest-specific API calls to their Vitest equivalents.

Key changes:

  • Replaced Jest with Vitest as the test runner
  • Migrated all jest.fn(), jest.spyOn(), and jest.Mock references to Vitest equivalents
  • Added Vitest configuration files for both formik and formik-native packages
  • Updated test scripts and removed Jest-specific configuration from package.json

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
yarn.lock Added Vitest and related dependencies, removed Jest types
packages/formik/vitest.config.ts New Vitest configuration with jsdom environment and coverage settings
packages/formik-native/vitest.config.ts New Vitest configuration for native package
packages/formik/package.json Updated test scripts and dependencies for Vitest
packages/formik-native/package.json Updated test scripts and added Vitest dependency
packages/formik/test/*.test.tsx Migrated Jest API calls to Vitest equivalents
packages/formik/test/setupTests.ts Updated with Vitest imports and jest-dom configuration
.github/CONTRIBUTING.md Updated documentation to reference Vitest
package.json Removed @types/jest from root dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants