Skip to content

Add unit testing framework with Jest and React Testing Library#4

Open
bigweavergammainternal[bot] wants to merge 1 commit intomainfrom
dev-branch-20260127-024153
Open

Add unit testing framework with Jest and React Testing Library#4
bigweavergammainternal[bot] wants to merge 1 commit intomainfrom
dev-branch-20260127-024153

Conversation

@bigweavergammainternal
Copy link
Copy Markdown

This pull request was generated by @kiro-agent 👻

Comment with /kiro fix to address specific feedback or /kiro all to address everything.
Learn about Kiro autonomous agent


Summary

This PR establishes a comprehensive unit testing infrastructure for the Next.js application to improve code quality, maintainability, and reliability. The implementation enables the team to systematically address technical debt and ensure new features meet quality standards.

Testing Framework Setup:

  • Added Jest with ts-jest for TypeScript support
  • Added React Testing Library for component testing
  • Added jest-environment-jsdom for DOM simulation
  • Created jest.config.js with Next.js integration and coverage configuration
  • Created jest.setup.js with necessary mocks for Amplify, fonts, and window APIs

Test Scripts:

  • npm test - Run all tests
  • npm run test:watch - Run tests in watch mode
  • npm run test:coverage - Generate coverage reports

App Component Tests (app/page.tsx):

  • Component rendering tests (headings, buttons, links, empty state)
  • listTodos() behavior tests (observeQuery subscription, data display, updates)
  • createTodo() behavior tests (prompt handling, todo creation, edge cases)
  • User interaction flow tests (multiple todo creation, list rendering)

RootLayout Component Tests (app/layout.tsx):

  • Children rendering tests (single, multiple, nested)
  • HTML structure tests (lang attribute, proper hierarchy)
  • Font configuration tests (Inter font application)
  • Metadata export validation tests

Amplify Configuration Tests:

  • Auth resource tests (amplify/auth/resource.ts) - email login configuration validation
  • Data resource tests (amplify/data/resource.ts) - schema definition, authorization modes, API key configuration

Dependencies Added:

  • jest@^29.7.0
  • jest-environment-jsdom@^29.7.0
  • ts-jest@^29.2.5
  • @testing-library/react@^16.0.1
  • @testing-library/jest-dom@^6.5.0
  • @types/jest@^29.5.12

######[This description was generated by Claude]

- Add Jest, ts-jest, and React Testing Library dependencies
- Create jest.config.js with Next.js integration
- Create jest.setup.js with necessary mocks
- Add test scripts to package.json
- Add unit tests for App component (page.tsx)
- Add unit tests for RootLayout component (layout.tsx)
- Add unit tests for Amplify auth resource
- Add unit tests for Amplify data resource schema
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.

1 participant