Conversation
- Introduced Jest configuration in jest.config.ts for testing Next.js applications. - Added jest.setup.ts to include custom matchers from @testing-library/jest-dom. - Updated package.json to include test scripts and added necessary testing libraries in devDependencies. - Updated package-lock.json to reflect new dependencies for testing.
- Introduced comprehensive Jest tests for the stats and streaks utilities, covering functions such as getCompletionRate, getBestStreak, getTotalDaysTracked, and getAverageCompletionRate. - Added tests for calculating streaks, including handling gaps and incomplete days. - Ensured proper date formatting and logging behavior in test scenarios.
- Introduced Jest tests for AddHabitModal, covering rendering, input validation, and form submission. - Added tests for HabitCard, validating rendering of habit details and interaction in different modes. - Mocked necessary dependencies to ensure isolated testing of components.
- Introduced Jest tests for CalendarPage, covering loading states, empty states, habit selection, and month navigation. - Added Jest tests for StatsPage, validating loading, error handling, empty states, and stats rendering. - Mocked necessary dependencies and data to ensure isolated testing of components.
- Introduced a new GitHub Actions workflow to automate testing on push and pull request events for the main and develop branches. - Configured the workflow to set up Node.js, install dependencies, and run tests using npm. - Ensured the testing environment runs on the latest Ubuntu version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
This PR adds a comprehensive testing infrastructure to the project using Jest and React Testing Library. It includes unit tests for critical logic functions and component tests for key UI elements, along with CI automation via GitHub Actions.
🔗 Related Issue
Closes #28
🏷️ Type of Change
🔄 Changes Made
jest.config.tsandjest.setup.tsfor Next.js configurationlib/streaks.ts(streak calculation logic)lib/stats.ts(statistics functions)HabitCardandAddHabitModalCalendarPageandStatsPage.github/workflows/tests.yml) to run tests on push/PR🧪 Testing
All tests pass locally:
✅ Checklist
📸 Screenshots (if applicable)
N/A - This PR adds testing infrastructure, no UI changes.
📌 Additional Notes
New Files
jest.config.tsjest.setup.tslib/__tests__/streaks.test.tslib/__tests__/stats.test.tscomponents/habits/__tests__/HabitCard.test.tsxcomponents/habits/__tests__/AddHabitModal.test.tsxapp/dashboard/calendar/__tests__/page.test.tsxapp/dashboard/stats/__tests__/page.test.tsx.github/workflows/tests.ymlNew Scripts
npm test- Run all testsnpm run test:watch- Run tests in watch mode