-
-
Notifications
You must be signed in to change notification settings - Fork 705
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
Migrated Jest to Vitest for Organizations folder #2626
base: main
Are you sure you want to change the base?
Migrated Jest to Vitest for Organizations folder #2626
Conversation
WalkthroughThe pull request introduces several modifications primarily to the Changes
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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.
Congratulations on making your first PR! 🎊 If you haven't already, check out our Contributing Guidelines and PR Reporting Guidelines to ensure that you are following our guidelines for contributing and creating PR.
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: 2
🧹 Outside diff range and nitpick comments (2)
src/screens/UserPortal/Organizations/Organizations.test.tsx (2)
336-338
: Consider using beforeEach for mock setupThe mock setup should ideally be within a test lifecycle hook for better test isolation.
Apply this diff to improve the mock setup:
-vi.mock('utils/useLocalstorage', () => ({ - getItem: vi.fn(() => 'mockUserId'), -})); +describe('Testing Organizations Screen [User Portal]', () => { + beforeEach(() => { + vi.mock('utils/useLocalstorage', () => ({ + getItem: vi.fn(() => 'mockUserId'), + })); + });
568-568
: Add newline at end of fileAdd a newline at the end of the file to follow best practices.
-}); +}); +🧰 Tools
🪛 eslint
[error] 568-568: Insert
⏎
(prettier/prettier)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (4)
package.json
(5 hunks)src/screens/UserPortal/Organizations/Organizations.test.tsx
(3 hunks)vitest.config.ts
(1 hunks)vitest.setup.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- vitest.setup.ts
- vitest.config.ts
🧰 Additional context used
🪛 eslint
src/screens/UserPortal/Organizations/Organizations.test.tsx
[error] 568-568: Insert ⏎
(prettier/prettier)
🔇 Additional comments (1)
src/screens/UserPortal/Organizations/Organizations.test.tsx (1)
18-18
: LGTM: Correct Vitest import
The import of vi
from 'vitest' is correctly added to replace Jest's mocking functionality.
"test": "cross-env NODE_ENV=test jest --env=./scripts/custom-test-env.js --watchAll --coverage", | ||
"test:jest": "cross-env NODE_ENV=test jest --env=./scripts/custom-test-env.js", | ||
"test:vitest": "vitest --run", | ||
"test:vitest:watch": "vitest", | ||
"test:vitest:coverage": "vitest --coverage", |
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.
🛠️ Refactor suggestion
Consider consolidating test scripts
The presence of both Jest and Vitest test scripts might cause confusion. Since we're migrating to Vitest, consider:
- Deprecating Jest scripts
- Renaming Vitest scripts to be the default
Apply this diff to consolidate the scripts:
- "test": "cross-env NODE_ENV=test jest --env=./scripts/custom-test-env.js --watchAll --coverage",
- "test:jest": "cross-env NODE_ENV=test jest --env=./scripts/custom-test-env.js",
- "test:vitest": "vitest --run",
- "test:vitest:watch": "vitest",
- "test:vitest:coverage": "vitest --coverage",
+ "test": "vitest --run",
+ "test:watch": "vitest",
+ "test:coverage": "vitest --coverage",
+ "test:jest-legacy": "cross-env NODE_ENV=test jest --env=./scripts/custom-test-env.js"
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
"test": "cross-env NODE_ENV=test jest --env=./scripts/custom-test-env.js --watchAll --coverage", | |
"test:jest": "cross-env NODE_ENV=test jest --env=./scripts/custom-test-env.js", | |
"test:vitest": "vitest --run", | |
"test:vitest:watch": "vitest", | |
"test:vitest:coverage": "vitest --coverage", | |
"test": "vitest --run", | |
"test:watch": "vitest", | |
"test:coverage": "vitest --coverage", | |
"test:jest-legacy": "cross-env NODE_ENV=test jest --env=./scripts/custom-test-env.js" |
"@testing-library/jest-dom": "^6.6.3", | ||
"@testing-library/react": "^16.1.0", |
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.
💡 Codebase verification
Version incompatibility detected with @testing-library/react
The current setup has incompatible versions:
- @testing-library/[email protected] requires React ^18.0.0 || ^19.0.0
- Your project uses React ^18.3.1
- However, @testing-library/react version 16.1.0 appears to be incorrect as the latest major version is 14.x
Recommendation:
- Downgrade to @testing-library/react ^14.1.2 which is the latest stable version compatible with React 18
The other dependencies (@testing-library/jest-dom, vitest, jsdom) show no direct compatibility issues.
🔗 Analysis chain
Verify version compatibility
The updated testing libraries have significant version changes. Ensure compatibility between:
- @testing-library/jest-dom ^6.6.3
- @testing-library/react ^16.1.0
- @vitest/coverage-v8 ^2.1.8
- jsdom ^25.0.1
- vitest ^2.1.8
Also applies to: 129-129, 137-137, 152-152, 158-158
Let me check the React version in package.json to verify compatibility.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for any reported compatibility issues between these versions
npm info @testing-library/[email protected] peerDependencies
npm info @testing-library/[email protected] peerDependencies
npm info [email protected] peerDependencies
Length of output: 509
Script:
#!/bin/bash
# Check React version in package.json
cat package.json | grep -A 1 '"react":'
Length of output: 103
Please fix the failing tests and make sure code rabbit.ai approves your changes |
@CoyoteClear340 Please fix the failing tests and ensure coderabbit approves your PR. |
What kind of change does this PR introduce?
Migration from Jest to Vitest for the
Organizations
folder.Issue Number:
Fixes ##2575
Did you add tests for your changes?
Yes, existing tests were migrated from Jest to Vitest.
Snapshots/Videos:
If relevant, did you update the documentation?
No
Summary
This PR migrates all Jest tests in the
Organizations
folder to Vitest. The changes include:npm run test:vitest
.Does this PR introduce a breaking change?
No
Other information
Have you read the contributing guide?
Yes
Summary by CodeRabbit
New Features
chart.js
library.Bug Fixes
Documentation
@testing-library/jest-dom
.Chores