Add comprehensive unit test suite with Jest for Next.js + Amplify app#8
Open
bigweavergammainternal[bot] wants to merge 1 commit intomainfrom
Open
Add comprehensive unit test suite with Jest for Next.js + Amplify app#8bigweavergammainternal[bot] wants to merge 1 commit intomainfrom
bigweavergammainternal[bot] wants to merge 1 commit intomainfrom
Conversation
- Set up Jest with ts-jest, jsdom environment, and Testing Library - Add unit tests for App component (rendering, observeQuery, createTodo, UI) - Add unit tests for RootLayout component (children rendering, metadata) - Add unit tests for Amplify data resource (schema, Todo model, auth rules) - Add unit tests for Amplify auth resource (defineAuth, email login config) - Add unit tests for backend definition (defineBackend with auth and data) - Add mocks for CSS/static files and AWS Amplify modules - Add Dockerfile and .dockerignore for containerized test execution - Add test and test:coverage npm scripts to package.json
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
Problem
The amplify-next-template repository has no testing framework or unit tests, leaving the codebase without automated quality assurance. This gap makes it harder to catch regressions, validate behavior of Amplify integrations, and maintain confidence during future development.
Solution
Set up a complete Jest-based testing infrastructure and add comprehensive unit tests covering all key modules in the project.
Testing Framework Setup
ts-jesttransform for TypeScript/JSX support@/path aliases@aws-amplifyandaws-amplifymodulesjest.setup.tsfor global test matchersstyleMock.ts) and static files (fileMock.ts)Unit Tests Added
app/page.tsx)__tests__/app/page.test.tsxobserveQuerysubscription & state updates,createTodovia prompt, UI interactionsapp/layout.tsx)__tests__/app/layout.test.tsxlangattribute, metadata export validationamplify/data/resource.ts)__tests__/amplify/data/resource.test.tscontentfield,publicApiKeyauthorization,defineDataconfig withapiKeyauth modeamplify/auth/resource.ts)__tests__/amplify/auth/resource.test.tsdefineAuthinvocation, email-based login configurationamplify/backend.ts)__tests__/amplify/backend.test.tsdefineBackendcalled with correctauthanddataresourcesAdditional Files
Dockerfileand.dockerignorefor containerized test executionnpm testandnpm run test:coveragescripts added topackage.jsonjest,ts-jest,jest-environment-jsdom,@testing-library/react,@testing-library/jest-dom,@types/jestNotes
generateClient,defineAuth,defineData,defineBackend) are fully mocked to isolate unit test behavior from cloud servicespackage-lock.jsonis not updated in this PR; dependencies should be installed vianpm installafter mergebase-custom-mcp-image:latestas a base image for containerized test runs