A live-coding test repository for evaluating senior front-end engineer candidates. The challenge involves building a simple counter application using React and TDD.
Build a simple counter application using React. The counter application should have the following functionalities:
- Display a number (starts at 0).
- Have an "Increment" button to increase the count by 1.
- Have a "Decrement" button to decrease the count by 1.
- Ensure the counter never goes below 0.
- TDD: Use Test-Driven Development to build this application. You can use libraries like Jest and React Testing Library.
- Styling: The application should be styled, either with inline styles or CSS classes.
- Real-time Updates: The counter should update in real-time when the buttons are clicked.
- Code Quality: Pay attention to code quality, readability, and maintainability.
- Add a "Reset" button that resets the count to 0.
- Make the application accessible (e.g., keyboard navigation, screen reader support).
- Setup: Initialize a new React application and install any necessary testing libraries.
- Write Tests: Start by writing a test case for displaying the counter.
- Implementation: Write the minimal code required to pass the test.
- Refactoring: Refactor the code if necessary.
- Repeat: Continue this process for the "Increment" and "Decrement" functionalities.
- Styling: After the functionality is implemented and all tests pass, add styling to the application.
- Bonus: If time permits, work on the bonus features.
Consider these example test cases:
- The application should render a counter display.
- The application should render an "Increment" button.
- The application should render a "Decrement" button.
- Clicking "Increment" should increase the counter by 1.
- Clicking "Decrement" should decrease the counter by 1.
- The counter should not go below 0.
Feel free to add other test cases.