Skip to content

Add Jest + React Testing Library test suite#14

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

Add Jest + React Testing Library test suite#14
ghostyappbeta[bot] wants to merge 2 commits intomainfrom
add-tests

Conversation

@ghostyappbeta
Copy link
Copy Markdown

@ghostyappbeta ghostyappbeta bot commented Mar 17, 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 complete test framework and test suite to the project, which previously had no tests at all.

Changes

Test framework setup:

  • Installed Jest, React Testing Library (@testing-library/react, @testing-library/jest-dom, @testing-library/user-event), jest-environment-jsdom, @types/jest, and identity-obj-proxy
  • Created jest.config.ts using next/jest.js with JSDOM environment, CSS module mocking, @/* path alias support, and amplify_outputs.json mock
  • Created jest.setup.ts importing @testing-library/jest-dom
  • Created __mocks__/mock_amplify_outputs.json and __mocks__/styleMock.js
  • Added "test": "jest" and "test:watch": "jest --watch" scripts to package.json

Component tests:

  • __tests__/app/page.test.tsx (7 tests): heading, button, link, success message rendering; observeQuery/subscribe called on mount; todo items displayed from subscription; button click triggers window.prompt then Todo.create
  • __tests__/app/layout.test.tsx (4 tests): children rendering, <html lang="en">, <body> with Inter font className, exported metadata

Test results

Test Suites: 2 passed, 2 total
Tests:       11 passed, 11 total

All tests exercise actual component logic and would fail if corresponding code were changed.

kiro-agent and others added 2 commits March 17, 2026 23:41
- Install jest, @testing-library/react, @testing-library/jest-dom,
  @testing-library/user-event, jest-environment-jsdom, @types/jest,
  and identity-obj-proxy as dev dependencies
- Create jest.config.ts using next/jest createJestConfig helper with
  jsdom environment, CSS module mocking, @/* path alias support,
  and amplify_outputs.json mock mapping
- Create jest.setup.ts importing @testing-library/jest-dom
- Create __mocks__/mock_amplify_outputs.json with minimal structure
- Create __mocks__/styleMock.js for plain CSS imports
- Add test and test:watch scripts to package.json

Co-authored-by: ningkehu <168601733+ningkehu@users.noreply.github.com>
- Add 7 tests for App component (page.tsx): heading, button, link,
  success message, observeQuery subscription, todo display on data
  emission, and window.prompt + Todo.create on button click
- Add 4 tests for RootLayout (layout.tsx): children rendering, html
  lang attribute, body font className, and metadata exports
- Fix jest.config.ts moduleNameMapper to catch SWC-resolved
  amplify_outputs.json paths (next/jest SWC transforms @/ aliases
  before moduleNameMapper runs)

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.

1 participant