-
Notifications
You must be signed in to change notification settings - Fork 465
feat(frontend): add Jest unit testing infrastructure #6432
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
base: revert-6428-revert-6361-refactor/migrate-critical-components-featurespagejs-2
Are you sure you want to change the base?
feat(frontend): add Jest unit testing infrastructure #6432
Conversation
- Add Jest with ts-jest for TypeScript support - Add jest.config.js with path aliases matching tsconfig - Add npm scripts: test:unit, test:unit:watch, test:unit:coverage - Migrate format.js to format.ts for better Jest compatibility - Add unit tests for featureFilterParams utility Tests cover: - buildUrlParams: is_archived always explicitly set (never undefined) - buildApiFilterParams: is_archived always included in API params - getFiltersFromParams: URL param parsing - hasActiveFilters: filter state detection This prevents regression of the archived features bug where is_archived was undefined instead of explicitly 'false'. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Runs Jest unit tests on PRs that modify frontend/ files. Runs on all PRs including drafts (tests are fast and cheap). Lint and typecheck can be added later once those are cleaned up. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
ef6d2cb to
0635372
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## revert-6428-revert-6361-refactor/migrate-critical-components-featurespagejs-2 #6432 +/- ##
================================================================================================================
Coverage ? 98.06%
================================================================================================================
Files ? 1292
Lines ? 46509
Branches ? 0
================================================================================================================
Hits ? 45611
Misses ? 898
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Docker builds report
|
- Add 45 unit tests for Format utility pure functions - Remove unnecessary .toString() in countdown: parseInt(x.toString()) → Math.floor(x) - Remove unnecessary .toString() in shortenNumber: +parseFloat(x.toString()).toFixed(1) → +x.toFixed(1) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add explicit moment import to fix TypeScript UMD global error - Simplify money() to consistently return defaultValue for null/undefined/0 - Update tests to reflect new behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Zaimwa9
left a comment
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.
Just adding a prop and to the deploy to production pipeline and should be good to go. Thanks for the initiative!
| @@ -0,0 +1,33 @@ | |||
| name: Frontend Pull Requests | |||
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.
Let's also add the tests in the deploy to production workflow
| @@ -0,0 +1,30 @@ | |||
| /** @type {import('jest').Config} */ | |||
| module.exports = { | |||
| collectCoverageFrom: [ | |||
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.
I remember a clearMocks prop maybe that could be worth adding
Summary
Add Jest unit testing infrastructure to the frontend codebase to enable fast, isolated unit tests alongside the existing TestCafe E2E tests.
Closes #6442
Changes
Jest Configuration
ts-jestpreset for TypeScript supportcommon/,components/,project/)common/andweb/directoriesCI/CD Integration
frontend-pull-request.yml)Initial Test Coverage
featureFilterParamsutilitybuildUrlParams,buildApiFilterParams,getFiltersFromParams,hasActiveFiltersDependencies Added
jest,ts-jest,@types/jestHow did you test this code?
cd frontend npm run test:unitAll 27 tests pass.
Checklist
docs/if required so people know about the feature!