Skip to content

Migrate PointerBox tests from Jest to Vitest #6407

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 28, 2025

This PR migrates the PointerBox component tests from Jest to Vitest as part of the broader test suite migration effort.

Changes Made

  • Updated configuration files: Added PointerBox to the Vitest browser config include list and excluded it from Jest's modulePathIgnorePatterns
  • Migrated test imports: Replaced Jest-specific imports with Vitest (describe, expect, it) and @testing-library/react (render)
  • Removed Jest-specific utilities:
    • Removed behavesAsComponent usage (component behavior tests)
    • Removed checkExports usage (module export validation)
    • Removed axe violations test with toHaveNoViolations (accessibility testing)
  • Fixed theme context issues: Used ThemeProvider wrapper for tests that require styled-components theme context, particularly for background color styling tests
  • Replaced render utilities: Replaced renderStyles function (which had Node.js dependencies incompatible with browser tests) with direct DOM manipulation using window.getComputedStyle
  • Updated snapshots: Regenerated snapshots in Vitest format to replace Jest snapshot format

Test Coverage

All 6 original tests have been successfully migrated and are passing:

  • ✅ Basic rendering with relative positioning
  • ✅ Border color via borderColor prop (backwards compatibility)
  • ✅ Border color via sx prop
  • ✅ Background color via bg prop (backwards compatibility)
  • ✅ Background color via sx prop
  • ✅ Background color consistency between bg prop and sx prop

The migration maintains full test functionality while adapting to Vitest's browser-based testing environment.

Fixes #6390.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copy link

changeset-bot bot commented Jul 28, 2025

⚠️ No Changeset found

Latest commit: 98dbcb3

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 PointerBox tests from Jest to Vitest Migrate PointerBox tests from Jest to Vitest Jul 28, 2025
@Copilot Copilot AI requested a review from joshblack July 28, 2025 20:14
Copilot finished work on behalf of joshblack July 28, 2025 20:14
Copy link
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

@copilot make sure to also pull in the latest changes from main and address merge conflicts

})

it('applies the border color via "borderColor" prop for backwards compatibility', () => {
expect(render(<PointerBox borderColor="danger.emphasis" />)).toMatchSnapshot()
expect(render(<PointerBox borderColor="danger.emphasis" theme={theme} />)).toMatchSnapshot()
Copy link
Member

Choose a reason for hiding this comment

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

Update this test from a snapshot test to one that is checking that the border color is set correctly

})

it('applies the border color via sx prop', () => {
expect(render(<PointerBox sx={{borderColor: 'danger.emphasis'}} />)).toMatchSnapshot()
expect(render(<PointerBox sx={{borderColor: 'danger.emphasis'}} theme={theme} />)).toMatchSnapshot()
Copy link
Member

Choose a reason for hiding this comment

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

Update this test from a snapshot test to one that is checking that the border color is set correctly

const {container} = HTMLRender(<PointerBox />)
const results = await axe.run(container)
expect(results).toHaveNoViolations()
expect(render(<PointerBox theme={theme} />)).toMatchSnapshot()
Copy link
Member

Choose a reason for hiding this comment

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

Remove this test

<PointerBox bg="danger.emphasis" />
</ThemeProvider>,
),
).toMatchSnapshot()
Copy link
Member

Choose a reason for hiding this comment

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

Update this test from a snapshot test to one that is checking the background color

})

it('applies the background color via sx prop', () => {
expect(render(<PointerBox sx={{bg: 'danger.emphasis'}} />)).toMatchSnapshot()
expect(
Copy link
Member

Choose a reason for hiding this comment

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

Update this test from a snapshot test to one that is checking the background color

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.

Update PointerBox tests from Jest to Vitest
2 participants