Write test first (red), implement to pass (green), refactor (refactor). TDD ensures tests drive design and keep code testable.
// Red: write test first
test('factorial of 0 is 1', () => {
expect(factorial(0)).toBe(1);
});
test('factorial of 5 is 120', () => {
// ...Write test first (red), implement to pass (green), refactor (refactor). TDD ensures tests drive design and keep code testable.
// Red: write test first
test('factorial of 0 is 1', () => {
expect(factorial(0)).toBe(1);
});
test('factorial of 5 is 120', () => {
// ...