Add unit tests with Jest and React Testing Library for core application modules#10
Open
bigweavergammainternal[bot] wants to merge 1 commit intomainfrom
Open
Add unit tests with Jest and React Testing Library for core application modules#10bigweavergammainternal[bot] wants to merge 1 commit intomainfrom
bigweavergammainternal[bot] wants to merge 1 commit intomainfrom
Conversation
- Set up Jest with React Testing Library for testing Next.js components - Add jest.config.ts with next/jest integration, jsdom environment, and module path mapping - Add jest.setup.ts with @testing-library/jest-dom matchers - Add test script to package.json Test coverage: - app/page.tsx: Rendering, todo creation, todo listing, state management with mocked generateClient - app/layout.tsx: Children rendering, HTML structure, font class application - amplify/data/resource.ts: Schema definition, Todo model fields, authorization rules - amplify/auth/resource.ts: Auth resource definition, email login configuration - amplify/backend.ts: Backend configuration with auth and data resources Dependencies added: - jest, jest-environment-jsdom, @types/jest - @testing-library/react, @testing-library/jest-dom, @testing-library/user-event - ts-node Also add Dockerfile and .dockerignore for development/testing
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.
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
Notes
This PR introduces a comprehensive unit testing setup for the amplify-next-template repository using Jest and React Testing Library. The goal is to establish a solid testing foundation that covers the core application components and Amplify backend configuration modules, enabling confidence in future refactoring and feature development.
What changed and why
Testing framework setup:
next/jestfor seamless Next.js integration, usingjsdomtest environment for DOM-based component testing.jest.config.tswith module name mapping for path aliases (@/) and.jsextension resolution.jest.setup.tsto import@testing-library/jest-domcustom matchers globally.testscript topackage.jsonfor running the test suite vianpm test.New dev dependencies:
jest,jest-environment-jsdom,@types/jest— Core testing framework@testing-library/react,@testing-library/jest-dom,@testing-library/user-event— React component testing utilitiests-node— TypeScript support for Jest configTest coverage for application components:
app/page.tsx(App)app/layout.tsx(RootLayout)<html>and<body>tagsamplify/data/resource.tscontentfield, authorization rules (allow.owner())amplify/auth/resource.tsdefineAuthinvocation, email login configurationamplify/backend.tsdefineBackendinvocation, auth and data resource wiringAll AWS Amplify modules are tested using mocks (
jest.mock) andjest.isolateModulesto ensure clean module state between tests, avoiding side-effect leakage.Testing
npm test.generateClient) and backend definition functions to avoid external dependencies.