Skip to content

Update SelectPanel test from Jest to Vitest #6433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 4, 2025
Merged

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 1, 2025

This PR migrates the SelectPanel test file from Jest to Vitest as part of the broader test suite migration effort.

Changes Made

Configuration Updates:

  • Added <rootDir>/src/SelectPanel/ to the Jest modulePathIgnorePatterns in jest.config.js to exclude it from Jest runs
  • Added SelectPanel test pattern to the Vitest browser configuration to include it in Vitest runs

Test File Migration:

  • Updated imports to use Vitest (describe, expect, it, vi, beforeEach) instead of Jest
  • Replaced all Jest mocking functions:
    • jest.fn()vi.fn()
    • jest.useFakeTimers()vi.useFakeTimers()
    • jest.runAllTimers()vi.runAllTimers()
    • jest.useRealTimers()vi.useRealTimers()
    • jest.advanceTimersByTimevi.advanceTimersByTime
  • Replaced global.Element.prototype.scrollTo = jest.fn() with globalThis.Element.prototype.scrollTo = vi.fn() for browser compatibility
  • Removed setupMatchMedia() usage and import as specified in migration guidelines
  • Restored original import from ../utils/testing for the getLiveRegion utility

Testing

The SelectPanel test file has been successfully migrated to Vitest and added to the browser test configuration. The tests will now run as part of the Vitest component test suite using the browser environment.

Fixes #6381.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI assigned Copilot and pksjce Aug 1, 2025
Copy link

changeset-bot bot commented Aug 1, 2025

⚠️ No Changeset found

Latest commit: b2c8b9b

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

@Copilot Copilot AI changed the title [WIP] Update SelectPanel test from Jest to Vitest Update SelectPanel test from Jest to Vitest Aug 1, 2025
@Copilot Copilot AI requested a review from pksjce August 1, 2025 12:00
Copilot finished work on behalf of pksjce August 1, 2025 12:00
return liveRegion as LiveRegionElement
}
throw new Error('No live-region found')
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot - All this liveregion additions are not required. remove them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the local live region implementation and restored the original import from ../utils/testing as requested. (1d11df5)

@Copilot Copilot AI requested a review from pksjce August 4, 2025 01:31
Copilot finished work on behalf of pksjce August 4, 2025 01:31
@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Aug 4, 2025
Copy link
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!

@pksjce pksjce added the skip changeset This change does not need a changelog label Aug 4, 2025
@pksjce
Copy link
Contributor

pksjce commented Aug 4, 2025

@copilot - Its just test file changes. Integration tests are not needed. Remove the tag

@pksjce pksjce marked this pull request as ready for review August 4, 2025 02:01
@Copilot Copilot AI review requested due to automatic review settings August 4, 2025 02:01
@pksjce pksjce requested a review from a team as a code owner August 4, 2025 02:01
Copy link
Contributor

@Copilot 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 SelectPanel test file from Jest to Vitest as part of the broader test framework migration effort. The changes ensure proper configuration separation between Jest and Vitest while maintaining test functionality.

Key changes:

  • Updated test framework imports and mocking functions from Jest to Vitest syntax
  • Configured Vitest to include SelectPanel tests and Jest to exclude them
  • Replaced browser compatibility issues with globalThis instead of global

Reviewed Changes

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

File Description
vitest.config.browser.mts Added SelectPanel test inclusion pattern for Vitest
SelectPanel.test.tsx Migrated all Jest syntax to Vitest equivalents and removed Node.js dependencies
jest.config.js Added SelectPanel directory to Jest ignore patterns
Comments suppressed due to low confidence (1)

packages/react/src/SelectPanel/SelectPanel.test.tsx:10

  • The import from '../utils/testing' may cause issues in the browser environment as mentioned in the PR description. Consider implementing a local version of getLiveRegion or ensure this import is compatible with Vitest's browser environment.
import {getLiveRegion} from '../utils/testing'

Copy link
Contributor

github-actions bot commented Aug 4, 2025

size-limit report 📦

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

Copy link
Contributor Author

Copilot AI commented Aug 4, 2025

@copilot - Its just test file changes. Integration tests are not needed. Remove the tag

Removed SelectPanel from browser vitest configuration since it only contains test file changes and doesn't need integration testing. (9bc54ee)

Copilot finished work on behalf of pksjce August 4, 2025 02:11
Copy link
Contributor Author

Copilot AI commented Aug 4, 2025

@copilot - Add this test file to vitest too

Added SelectPanel test file to the Vitest browser configuration following the same pattern as other component tests in the codebase. (1840ec4)

Copilot finished work on behalf of pksjce August 4, 2025 04:21
Copy link
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 github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Aug 4, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-6433 August 4, 2025 04:31 Inactive
@joshblack joshblack added this pull request to the merge queue Aug 4, 2025
Merged via the queue into main with commit 8ca1021 Aug 4, 2025
43 checks passed
@joshblack joshblack deleted the copilot/fix-6381-2 branch August 4, 2025 18:41
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update SelectPanel test from Jest to Vitest
3 participants