8000 chore: replace sinon with vitest's vi by simonguo · Pull Request #4289 · rsuite/rsuite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: replace sinon with vitest's vi #4289

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 8 commits into from
May 23, 2025
Merged

chore: replace sinon with vitest's vi #4289

merged 8 commits into from
May 23, 2025

Conversation

simonguo
Copy link
Member

This pull request focuses on replacing the usage of the sinon library with the vi testing utility from vitest across multiple test files.

@simonguo simonguo requested a review from Copilot May 20, 2025 14:34
Copy link
codesandbox bot commented May 20, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
codesandbox-ci bot commented May 20, 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.

Copy link
@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 replaces the use of the sinon library with Vitest’s built-in vi utility across test files.

  • Swapped out all sinon.spy()/sinon.useFakeTimers() calls for vi.fn()/vi.useFakeTimers() and restored timers with vi.useRealTimers().
  • Updated all assertion styles from Sinon/Vendor syntax (to.have.been.called, to.have.callCount) to Vitest matchers (toHaveBeenCalled(), toHaveBeenCalledTimes()).
  • Added vi to Vitest imports where needed and removed unused sinon imports.

Reviewed Changes

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

Show a summary per file
File Description
src/CascadeTree/test/TreeView.spec.tsx Replaced sinon.spy() with vi.fn() and updated assertions
src/CascadeTree/test/CascadeTree.spec.tsx Swapped sinon spies for vi.fn(), migrated call count and mocks
src/Carousel/test/Carousel.spec.tsx Converted sinon.spy() to vi.fn() and updated assertion syntax
src/Calendar/test/CalendarTimeDropdown.spec.tsx Replaced sinon.spy() with vi.fn() and updated matchers
src/Calendar/test/CalendarMonthDropdownItem.spec.tsx Swapped in vi.fn() for spies, updated call assertions
src/Calendar/test/CalendarMonthDropdown.spec.tsx Replaced sinon spies with vi.fn() and migrated matchers
src/Calendar/test/CalendarHeader.spec.tsx Converted sinon spies to vi.fn() and updated assertions
src/Calendar/test/CalendarGridRow.spec.tsx Replaced sinon.spy() with vi.fn() and updated assertion style
src/Calendar/test/CalendarGridCell.spec.tsx Swapped out sinon for vi.fn() and updated call assertions
src/Calendar/test/CalendarContainer.spec.tsx Migrated sinon.spy() to vi.fn(), adjusted assertion matchers
src/Calendar/test/Calendar.spec.tsx Replaced sinon timers and spies with vi.useFakeTimers(), vi.fn(), and updated assertions
src/Button/test/Button.spec.tsx Entire file deleted (Button tests removed)
src/Breadcrumb/test/BreadcrumbItem.spec.tsx Swapped sinon.spy() for vi.fn() and migrated assertions
src/Breadcrumb/test/Breadcrumb.spec.tsx Replaced sinon spies with vi.fn(), updated console spy usage
src/AutoComplete/test/utils.spec.ts Removed sinon, added vi, and updated filter test assertions
src/AutoComplete/test/AutoComplete.spec.tsx Converted sinon.spy() to vi.fn() and updated assertion syntax
src/Animation/test/Transition.spec.tsx Entire file deleted (Transition tests removed)
src/Animation/test/Collapse.spec.tsx Swapped sinon spy for vi.fn() and updated assertions
src/Affix/test/Affix.spec.tsx Replaced sinon.spy() with vi.fn() and updated assertions
src/Accordion/test/Accordion.spec.tsx Swapped sinon spies for vi.fn() and updated expectation calls
Comments suppressed due to low confidence (2)

src/Button/test/Button.spec.tsx:1

  • The Button.spec.tsx file was deleted, removing all Button component tests and reducing test coverage. Confirm if deletion was intentional or restore these tests.
<entire file removed>

src/Animation/test/Transition.spec.tsx:1

  • The Transition.spec.tsx file has been removed, dropping all animation transition tests and potentially decreasing test coverage. Verify if this removal was intended.
<entire file removed>

@simonguo simonguo added this to the v6 milestone May 20, 2025
Copy link
vercel bot commented May 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rsuite-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2025 6:45am
rsuite-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2025 6:45am

Copy link
codecov bot commented May 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.26%. Comparing base (86597bd) to head (412b216).
Report is 2 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #4289      +/-   ##
==========================================
+ Coverage   94.14%   94.26%   +0.12%     
==========================================
  Files         544      543       -1     
  Lines       13262    13243      -19     
  Branches     3951     3948       -3     
==========================================
- Hits        12485    12484       -1     
+ Misses        707      690      -17     
+ Partials       70       69       -1     
Flag Coverage Δ
chromium 94.26% <100.00%> (+0.13%) ⬆️
firefox 94.26% <100.00%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@simonguo simonguo marked this pull request as ready for review May 22, 2025 06:56
@simonguo simonguo merged commit fe4a27b into next May 23, 2025
21 of 22 checks passed
@simonguo simonguo deleted the test/sinon-to-vitest branch May 23, 2025 01:29
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.

1 participant
0