Skip to content

Conversation

@rudransh-shrivastava
Copy link
Collaborator

@rudransh-shrivastava rudransh-shrivastava commented Oct 5, 2025

Resolves #2212

Proposed change

Mock framer-motion to fix jest unit test fails.

Jest 30 has stricter ESM module resolution. heroui uses framer-motion which has sub-dependencies that import .mjs files dynamically.
Recent issues jest/issues/15823 and commits like jest/pull/15824 may have fixed similar issues, but I am using the latest release of Jest (30.2.0).

The fix is weird considering error messages in dependabot version bump PR, it's more like a workaround I guess. It took a while to figure out.

Context

Checklist

  • I've read and followed the contributing guidelines.
  • I've run make check-test locally; all checks and tests passed.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 5, 2025

Summary by CodeRabbit

  • Tests

    • Improved test stability by mocking the animation library to ensure consistent rendering in test environments.
    • Upgraded the test runner to the latest major version for better performance and reliability.
  • Chores

    • Updated testing type definitions to align with the new test runner version.
    • General test environment maintenance to support smoother developer workflows.

Walkthrough

Updates Jest tooling to v30 in frontend/package.json and adds a framer-motion Jest mock in frontend/jest.setup.ts to render LazyMotion children directly during tests. No public APIs are changed.

Changes

Cohort / File(s) Summary of changes
Test setup: framer-motion mock
frontend/jest.setup.ts
Adds a Jest module mock for framer-motion using requireActual and overrides to ensure LazyMotion renders children directly in tests.
Tooling: Jest v30 migration
frontend/package.json
Bumps devDependencies: jest from ^29.7.0 to ^30.2.0 and @types/jest from ^29.5.14 to ^30.0.0.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

frontend

Suggested reviewers

  • kasya
  • arkid15r

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title Check ✅ Passed The title “Migrate Jest to v30” accurately summarizes the main change by indicating the upgrade of the test framework to version 30 and is concise and specific without extraneous details.
Linked Issues Check ✅ Passed The pull request updates Jest and its type definitions to v30 and implements a framer-motion mock to ensure all tests pass under the new ESM resolution rules, directly fulfilling the linked issue’s requirement to migrate Jest and maintain test compatibility (#2212).
Out of Scope Changes Check ✅ Passed All changes are focused on upgrading Jest and adding a necessary test mock for framer-motion to resolve ESM import issues, and there are no modifications unrelated to the objectives of migrating to Jest v30.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed The pull request description clearly explains that Jest is being migrated to v30 and framer-motion is being mocked to address strict ESM resolution errors, references the related issue and context, and aligns directly with the changes made in jest.setup.ts and package.json.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 5, 2025

@rudransh-shrivastava rudransh-shrivastava marked this pull request as ready for review October 5, 2025 12:56
@arkid15r arkid15r self-assigned this Oct 5, 2025
@arkid15r arkid15r enabled auto-merge October 5, 2025 16:19
@arkid15r arkid15r added this pull request to the merge queue Oct 5, 2025
Merged via the queue into OWASP:main with commit 6a543d6 Oct 5, 2025
25 checks passed
@rudransh-shrivastava rudransh-shrivastava deleted the feature/migrate-jest-29-to-30 branch October 7, 2025 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate jest to v30

2 participants