This project is designed to help developers learn and practice Test-Driven Development (TDD) with React. It provides a structured approach to building React components while following TDD principles. The project includes pre-written tests that you'll need to make pass by implementing the required functionality.
Your task is to create a simple React app that has working tests.
Clone this repo and submit PRs to your fork following the Git Flow conventions; we will not merge direct PRs to this repository.
- Understanding and implementing TDD in React
- Writing and running tests using Vitest and React Testing Library
- Building controlled components
- Implementing form validation
- Creating multi-step forms
- Understanding component composition
Note This project uses volta, so please set it up. Also, read: Why use Volta?
Ensure that you follow the TDD approach to writing your code.
The tests are available and marked as skip. Enable your tests by removing the .skip from test or describe.
Ensure that your milestone tests are passing before submitting the PR
src/
├── components/ # React components
├── **/*.spec.jsx # Spec test files
└── **/*.test.jsx # Test files
- Install dependencies:
pnpm i- Run tests in watch mode:
To enable watch mode tests, remove .skip from your tests and run:
pnpm test- Optional: Run tests with UI:
pnpm test:ui- Create a controlled input component
- Implement input validation
- Handle user interactions
- Build a sign-up form composed component
- Compose using the input components
- Implement form validation
- Add Next button functionality
- Enable/disable based on validation
- Handle form submission
- Create an OTP component
- Implement OTP input fields
- Add validation
- Implement multi-step form flow
- Add navigation between steps
- Handle state management
Starbucks has the following denotations for sizes:
Tall - Small glass
Grande - Regular glass
Venti - Big mug
Trenta - Biggest bucket
- Fork the repository
- Create your feature branch (
git switch -c feature/<feature-name>) - Follow the Git Flow workflow
- Commit your changes (
git commit -m 'Adds some amazing feature') - Push to the branch
- Open a Pull Request in your own repo
- Simple easy to understand video on (watch from 5:46:14): TDD with React by Eve Porcello
- Testing React by Kent C. Dodds
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to all contributors who have helped shape this project.
- Special thanks to Eve Porcello and Kent C. Dodds for their excellent testing resources.