Add Jest + React Testing Library test suite#14
Open
ghostyappbeta[bot] wants to merge 2 commits intomainfrom
Open
Add Jest + React Testing Library test suite#14ghostyappbeta[bot] wants to merge 2 commits intomainfrom
ghostyappbeta[bot] wants to merge 2 commits intomainfrom
Conversation
- 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>
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 complete test framework and test suite to the project, which previously had no tests at all.
Changes
Test framework setup:
@testing-library/react,@testing-library/jest-dom,@testing-library/user-event),jest-environment-jsdom,@types/jest, andidentity-obj-proxyjest.config.tsusingnext/jest.jswith JSDOM environment, CSS module mocking,@/*path alias support, andamplify_outputs.jsonmockjest.setup.tsimporting@testing-library/jest-dom__mocks__/mock_amplify_outputs.jsonand__mocks__/styleMock.js"test": "jest"and"test:watch": "jest --watch"scripts topackage.jsonComponent tests:
__tests__/app/page.test.tsx(7 tests): heading, button, link, success message rendering;observeQuery/subscribecalled on mount; todo items displayed from subscription; button click triggerswindow.promptthenTodo.create__tests__/app/layout.test.tsx(4 tests): children rendering,<html lang="en">,<body>with Inter font className, exported metadataTest results
All tests exercise actual component logic and would fail if corresponding code were changed.