| name | test-first-feature-dev |
| description | Implement features using test-driven development approach |
| license | MIT |
Test-First Feature Development
When to Use
- Implementing new features
- Adding significant functionality
- When high confidence is needed
- For complex business logic
Steps
1. Understand Requirements
- Read and analyze the feature requirements
- Identify acceptance criteria
- Clarify edge cases and error scenarios
- Break down into testable units
2. Write Test Cases
- Start with happy path tests
- Add edge case tests
- Add error scenario tests
- Consider boundary conditions
3. Write Failing Tests
- Write the test code first
- Run tests to confirm they fail
- Verify failure reason is correct
- Keep tests simple and focused
4. Implement Minimum Code
- Write just enough code to pass
- Don't over-engineer
- Focus on the current test
5. Make Tests Pass
- Run tests to verify pass
- If failing, debug and fix
- Confirm implementation is minimal
6. Refactor
- Review the implementation
- Identify code smells
- Refactor while keeping tests green
- Remove duplication
Test Structure Template
describe('FeatureName', () => {
describe('methodName or scenario', () => {
it('should do something specific', () => {
const input = 'test data';
const expected = 'expected result';
const result = functionUnderTest(input);
expect(result).toBe(expected);
});
});
});
Checklist