Skip to content

Add unit tests for Amplify Next Template#13

Open
ghostyappbeta[bot] wants to merge 2 commits intomainfrom
add-unit-tests-v3
Open

Add unit tests for Amplify Next Template#13
ghostyappbeta[bot] wants to merge 2 commits intomainfrom
add-unit-tests-v3

Conversation

@ghostyappbeta
Copy link
Copy Markdown

@ghostyappbeta ghostyappbeta bot commented Feb 21, 2026

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

  • Test infrastructure: Added bunfig.toml for test config and test/setup.ts which mocks all external dependencies (React, Next.js, AWS Amplify) with call-tracking
  • Auth tests (test/amplify/auth.test.ts): Verifies email login provider configuration
  • Data schema tests (test/amplify/data.test.ts): Verifies Todo model definition, API key auth mode, and 30-day expiry
  • Backend tests (test/amplify/backend.test.ts): Verifies auth + data backend composition
  • Page component tests (test/app/page.test.tsx): Verifies App component JSX structure (heading, button, list, link)
  • Layout tests (test/app/layout.test.ts): Verifies metadata exports and RootLayout structure
  • Next config tests (test/next-config.test.ts): Verifies next.config.js exports
  • package.json: Added "test": "bun test" script

Test Results

27 pass, 0 fail, 39 expect() calls
Ran 27 tests across 7 files [22.00ms]

Design Decisions

  • Used Bun's built-in test runner instead of Jest/Vitest to avoid adding npm dependencies
  • All external modules are mocked via mock.module() in a preloaded setup file
  • Tests focus on configuration correctness and component structure to catch regressions

root and others added 2 commits February 21, 2026 02:36
- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants