Add unit tests for Amplify Next Template#13
Open
ghostyappbeta[bot] wants to merge 2 commits intomainfrom
Open
Conversation
- Add bunfig.toml with test preload configuration - Create test/setup.ts mocking all external deps (react, aws-amplify, @aws-amplify/backend, next, CSS/JSON imports) via bun:test mock.module() - Add smoke test verifying test infrastructure works - Add 'test' script to package.json Co-authored-by: ningkehu <168601733+ningkehu@users.noreply.github.com>
- test/amplify/auth.test.ts: tests auth resource config (loginWith.email) - test/amplify/data.test.ts: tests data resource (schema, auth modes, apiKey expiry) - test/amplify/backend.test.ts: tests backend composition (auth + data) - test/app/page.test.tsx: tests App component JSX structure (h1, button, ul, link) - test/app/layout.test.ts: tests metadata and RootLayout (html lang, Inter font) - test/next-config.test.ts: tests next.config.js exports empty object All 27 tests pass across 7 files with 39 assertions. Co-authored-by: ningkehu <168601733+ningkehu@users.noreply.github.com>
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 covering all source files in the repository. Uses Bun's built-in test runner (
bun:test) which requires zero additional npm dependencies.Changes
bunfig.tomlfor test config andtest/setup.tswhich mocks all external dependencies (React, Next.js, AWS Amplify) with call-trackingtest/amplify/auth.test.ts): Verifies email login provider configurationtest/amplify/data.test.ts): Verifies Todo model definition, API key auth mode, and 30-day expirytest/amplify/backend.test.ts): Verifies auth + data backend compositiontest/app/page.test.tsx): Verifies App component JSX structure (heading, button, list, link)test/app/layout.test.ts): Verifies metadata exports and RootLayout structuretest/next-config.test.ts): Verifies next.config.js exports"test": "bun test"scriptTest Results
Design Decisions
mock.module()in a preloaded setup file