-
-
Notifications
You must be signed in to change notification settings - Fork 811
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
test: migrate errorHandler tests from Jest to Vitest #2842
test: migrate errorHandler tests from Jest to Vitest #2842
Conversation
WalkthroughThis pull request involves multiple changes across different files in the Talawa-admin project. The modifications primarily focus on refactoring test files from Jest to Vitest, updating the testing framework, and making minor adjustments to test configurations. The changes include updating mocking techniques, renaming test files, and ensuring compatibility with the Vitest testing framework. Changes
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 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: 0
🧹 Nitpick comments (1)
jest.config.js (1)
13-13
: Insert a line break to satisfy lint rules.A newline before the closing bracket resolves the lint suggestion and maintains consistent formatting.
... '!coverage/**', '!**/index.{js,ts}', '!**/*.d.ts', '!src/test/**', - '!vitest.config.ts',], + '!vitest.config.ts', +],🧰 Tools
🪛 eslint
[error] 13-13: Insert
⏎··
(prettier/prettier)
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
[failure] 13-13:
Insert⏎··
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.env.example
(0 hunks)jest.config.js
(1 hunks)src/components/AddOn/AddOn.spec.tsx
(0 hunks)src/screens/OrganizationDashboard/OrganizationDashboard.spec.tsx
(2 hunks)src/utils/errorHandler.spec.tsx
(2 hunks)
💤 Files with no reviewable changes (2)
- .env.example
- src/components/AddOn/AddOn.spec.tsx
🧰 Additional context used
📓 Learnings (2)
src/utils/errorHandler.spec.tsx (1)
Learnt from: bitbard3
PR: PalisadoesFoundation/talawa-admin#2588
File: src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx:145-155
Timestamp: 2024-12-02T04:20:11.745Z
Learning: In PRs focused solely on refactoring test cases from Jest to Vitest, avoid suggesting optimizations or changes outside the migration scope.
jest.config.js (1)
Learnt from: MayankJha014
PR: PalisadoesFoundation/talawa-admin#2619
File: vitest.config.ts:0-0
Timestamp: 2024-12-09T15:54:04.872Z
Learning: The files `scripts/custom-test-env.js`, `src/utils/i18nForTest.ts`, and `vitest.setup.ts` are not test files and should not be included in the test pattern.
🪛 eslint
jest.config.js
[error] 13-13: Insert ⏎··
(prettier/prettier)
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
jest.config.js
[failure] 13-13:
Insert ⏎··
🔇 Additional comments (5)
src/utils/errorHandler.spec.tsx (3)
5-5
: Good job migrating the imports to Vitest.
Switching from Jest's imports to Vitest's (describe
, it
, expect
, vi
) is correctly done here.
7-9
: Mock implementation updated correctly.
Replacing jest.mock
with vi.mock
and jest.fn()
with vi.fn()
follows the correct Vitest mocking approach.
26-26
: Clear mocks with vi.clearAllMocks
.
Using vi.clearAllMocks()
in place of jest.clearAllMocks()
is appropriate for Vitest.
src/screens/OrganizationDashboard/OrganizationDashboard.spec.tsx (2)
150-154
: Stable test initialization with waitFor
.
Waiting for the dashboard to complete loading before asserting improves the reliability of the test.
163-164
: Flexible matching for upcoming events.
Using a case-insensitive regex matcher (with { exact: false }
) makes the test more resilient to text changes.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop-postgres #2842 +/- ##
=====================================================
+ Coverage 68.60% 87.55% +18.94%
=====================================================
Files 296 313 +17
Lines 7358 8204 +846
Branches 1606 1848 +242
=====================================================
+ Hits 5048 7183 +2135
+ Misses 2069 827 -1242
+ Partials 241 194 -47 ☔ View full report in Codecov by Sentry. |
Closing.
|
Refactoring - Migration of test framework from Jest to Vitest
Fixes #2758
All existing tests have been successfully migrated from Jest to Vitest with 100% coverage maintained.
Snapshots/Videos:
Screencast.from.2024-12-25.01-31-39.mp4
If relevant, did I update the documentation?
This is a test framework migration without changes to functionality.
Summary
This PR migrates the errorHandler test file from Jest to Vitest as part of the ongoing testing framework migration. Changes include:
errorHandler.test.tsx
toerrorHandler.spec.tsx
Does this PR introduce a breaking change?
No
Other information
All tests pass with
npm run test:vitest
and maintain 100% coverage.Have i read the contributing guide?
Yes
Summary by CodeRabbit
Chores
.env.example
file, which served as a template for environment variable configuration.Tests
AddOn
component with mock implementations for Redux and i18n utilities.OrganizationDashboard
component, adding wait conditions and flexible assertions.errorHandler.spec.tsx
from Jest to Vitest, updating mock implementations accordingly.