Add unit test suite for app components and Amplify configuration#9
Open
bigweavergammainternal[bot] wants to merge 1 commit intomainfrom
Open
Add unit test suite for app components and Amplify configuration#9bigweavergammainternal[bot] wants to merge 1 commit intomainfrom
bigweavergammainternal[bot] wants to merge 1 commit intomainfrom
Conversation
- Set up testing framework using Node.js built-in test runner (node:test) with a custom TypeScript loader for .ts file support - Add test helper (ts-loader.js) that strips TypeScript syntax, converts ESM to CJS, and provides mock module registration - Add unit tests for amplify/auth/resource.ts (3 tests): - Verifies defineAuth is called to configure authentication - Verifies email is configured as the login mechanism - Verifies the auth configuration is exported - Add unit tests for amplify/data/resource.ts (8 tests): - Verifies schema defines a Todo model with content string field - Verifies authorization is set on the Todo model - Verifies defineData is called with apiKey authorization mode - Verifies API key expiration is set to 30 days - Add unit tests for app/layout.tsx (9 tests): - Verifies metadata title and description are properly defined - Verifies RootLayout renders children inside body element - Verifies html lang attribute and Inter font usage - Add unit tests for app/page.tsx (20 tests): - Verifies todo list UI rendering (heading, button, list) - Verifies createTodo function interaction (prompt, create call) - Verifies data subscription via observeQuery - Verifies AWS Amplify integration (generateClient, configure) - Add test script to package.json: npm test runs all 40 tests
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 project had no test framework or test files configured, leaving all source code without automated test coverage. This created a gap in quality assurance for the Next.js App Router components and AWS Amplify Gen 2 backend configuration.
Solution
Set up a zero-dependency testing framework using Node.js built-in test runner (
node:test) with a custom TypeScript loader, and added comprehensive unit tests across all key source files.Testing Framework Setup
node:testmodule — no additional test dependencies required__tests__/helpers/ts-loader.jsthat strips TypeScript syntax, converts ESM imports/exports to CJS, and resolves@/path aliasesModule._loadoverride, enabling isolation of AWS Amplify dependenciesnpm testcommand topackage.jsonusingnode --testwith auto-discovery of*.test.jsfilesTest Coverage (40 tests total)
app/page.tsx— App component (20 tests)createTodofunction interaction (prompt call, button wiring, Todo.create invocation)app/layout.tsx— RootLayout component (9 tests)amplify/auth/resource.ts— Auth configuration (3 tests)defineAuthis called to configure authenticationamplify/data/resource.ts— Data schema (8 tests)contentstring fielddefineDatais called withapiKeyas default authorization modeFiles Added/Modified
__tests__/helpers/ts-loader.jsnode:test__tests__/app/page.test.js__tests__/app/layout.test.js__tests__/amplify/auth/resource.test.js__tests__/amplify/data/resource.test.jspackage.jsontestscriptTesting
npm test@aws-amplify/backend,aws-amplify/data) are fully mocked to isolate component behavior from cloud services