Skip to content

Migrate testing infrastructure from Jest (CRA) to Vitest#12

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
migrate/vitest-testing-library
Open

Migrate testing infrastructure from Jest (CRA) to Vitest#12
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
migrate/vitest-testing-library

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented May 4, 2026

Summary

Migrates the testing infrastructure from Jest (via Create React App) to Vitest (Session C of 4-session parallel migration).

Changes:

  • Removed old testing libraries from dependencies: @testing-library/react (^12), @testing-library/jest-dom (^5), @testing-library/user-event (^13)
  • Installed new testing dependencies:
    • vitest (^2), jsdom, @vitejs/plugin-react (^4)
    • @testing-library/react (^16), @testing-library/jest-dom (^6), @testing-library/user-event (^14)
    • @testing-library/dom (peer dependency of @testing-library/react v16)
  • Created vitest.config.js with:
    • Path aliases matching CRA's jsconfig-style imports
    • jsdom test environment and global test APIs
    • esbuild configured to handle JSX in .js files (CRA convention)
    • react-dom/client alias to a compatibility shim for React 17
  • Added src/test/react-dom-client-shim.js — bridges @testing-library/react v16's dependency on react-dom/client (React 18 API) to work with React 17's ReactDOM.render. Can be removed once React is upgraded to v18+.
  • Updated src/setupTests.js — removed CRA boilerplate comments
  • Updated package.json test script: "test": "vitest"
  • Fixed src/App.test.jsx — replaced broken "learn react" test with a "renders without crashing" test wrapped in AlertProvider context

Note on version compatibility

@testing-library/react v16 requires React 18+, but this project currently uses React 17. A react-dom/client shim is provided to bridge this gap. Once React is upgraded to v18+ (potentially via another parallel migration session), the shim file and the react-dom/client alias in vitest.config.js can be removed.

Review & Testing Checklist for Human

  • Run npx vitest run to verify the test passes
  • Verify that the react-dom/client shim adequately bridges React 17 ↔ @testing-library/react v16
  • Check that path aliases in vitest.config.js match the project's import conventions
  • After merging other parallel migration PRs, verify no conflicts in package.json

Notes

  • Only test-related files were modified (App.test.jsx, setupTests.js, vitest.config.js, package.json). No component source files or index.js were touched.
  • Used Vitest v2 (with Vite 5) instead of Vitest v4 (Vite 8) because Vite 8's oxc parser does not support JSX in .js files, which is a CRA convention used throughout this codebase.
  • --legacy-peer-deps was required during install due to the React 17 / @testing-library/react v16 peer dependency mismatch.

Link to Devin session: https://app.devin.ai/sessions/a59ac023896c4ff68a1e13d94f593e3e
Requested by: @shahmir-masood


Devin Review

Status Commit
⚪ Not started

Run Devin Review

💡 Connect your GitHub account to enable automatic code reviews.

Open in Devin Review (Staging)

- Remove old testing libraries (@testing-library/react ^12, jest-dom ^5, user-event ^13)
- Install vitest, jsdom, @testing-library/react ^16, jest-dom ^6, user-event ^14, @vitejs/plugin-react
- Create vitest.config.js with path aliases, jsdom environment, and JSX-in-JS support
- Add react-dom/client compatibility shim for React 17
- Update setupTests.js (remove CRA comments)
- Update package.json test script to use vitest
- Fix App.test.jsx to render with AlertProvider context

Co-Authored-By: shahmir.masood <shahmir.masood@cognition.ai>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

0 participants