Add unit tests for Amplify Next.js template#12
Open
ghostyappbeta[bot] wants to merge 1 commit intomainfrom
Open
Add unit tests for Amplify Next.js template#12ghostyappbeta[bot] wants to merge 1 commit intomainfrom
ghostyappbeta[bot] wants to merge 1 commit intomainfrom
Conversation
Add comprehensive unit tests for all source files using node:test module with --experimental-strip-types for TypeScript and --experimental-test-module-mocks for module mocking. No npm packages required. Tests cover: - amplify/auth/resource.ts: verifies defineAuth called with email login config - amplify/data/resource.ts: verifies schema with Todo model and apiKey auth - amplify/backend.ts: verifies imports and defineBackend assembly - app/layout.tsx: verifies metadata export (title, description) - app/page.tsx: verifies component structure, imports, and Amplify integration - next.config.js: verifies empty config export All 30 tests pass with 0 failures.
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
Summary
Adds a comprehensive unit test suite for the Amplify Next.js template repository using Node.js 22's built-in test runner (
node:test). No external testing dependencies are required.Changes
testscript topackage.jsonamplify/auth/resource.ts— verifies auth configuration with email loginamplify/data/resource.ts— verifies data schema definition and authorization rulesamplify/backend.ts— verifies backend configuration imports and structureapp/layout.tsx— verifies metadata, root layout exports, and HTML structureapp/page.tsx— verifies client directive, Amplify configuration, todo CRUD operations, and component structurenext.config.js— verifies Next.js configuration exportTesting Approach
mock.module()for pure.tsAmplify resource files — tests actual module behavior by mocking@aws-amplify/backendreadFileSyncfor.tsxfiles — verifies code correctness without needing a JSX parserrequire()fornext.config.jsHow to run
npm testNotes
--experimental-strip-typesand--experimental-test-module-mocksflags