-
-
Notifications
You must be signed in to change notification settings - Fork 708
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
Refactor: jest to vitest: Fixes #2485 #2616
base: develop-postgres
Are you sure you want to change the base?
Refactor: jest to vitest: Fixes #2485 #2616
Conversation
WalkthroughThe changes in this pull request involve refactoring the test file Changes
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (3)
src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.spec.tsx (3)
156-162
: Consider adding mock reset in afterEachWhile the timer setup is correct, consider adding
vi.resetAllMocks()
in the afterEach block to ensure complete test isolation.afterEach(() => { vi.useRealTimers(); + vi.resetAllMocks(); });
190-190
: Consider using more specific spy assertionsThe
setTimeoutSpy
is only checked for being called, but not for its specific timing or callback. Consider adding more specific assertions:- expect(setTimeoutSpy).toHaveBeenCalled(); + expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), expect.any(Number));Also applies to: 358-358, 407-407
546-547
: Replace vi.runAllTimersAsync with more specific timer advancementInstead of running all timers asynchronously, consider using a more specific timer advancement to make the test more predictable:
- await waitFor(async () => { - vi.runAllTimersAsync(); - }); + await waitFor(() => { + vi.advanceTimersByTime(300); // Replace 300 with the expected timeout duration + });
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.spec.tsx
(16 hunks)
🔇 Additional comments (1)
src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.spec.tsx (1)
37-41
: LGTM: Mock implementations correctly migrated to Vitest
The mock implementations have been properly migrated from Jest to Vitest, maintaining the same functionality while adapting to Vitest's syntax.
Also applies to: 144-153
src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.spec.tsx
Outdated
Show resolved
Hide resolved
Here is the PR that is unable to mock |
src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.spec.tsx
Show resolved
Hide resolved
src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.spec.tsx
Outdated
Show resolved
Hide resolved
src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.spec.tsx
Show resolved
Hide resolved
I had one global usefake and usereal for all. I removed them and added individually for the ones which needed and were suggested. It still fails. It shows like previous, it's a timeout issue Error: |
Please fix the failing tests |
What kind of change does this PR introduce?
Refractor from jest to vitest
Issue Number:
Fixes #2485
Snapshots/Videos:
Have you read the contributing guide?
yes
Summary by CodeRabbit
AdvertisementRegister
component, enhancing readability and efficiency.