Rule Title
Brief one-sentence description of the principle.
Bad Example
// Comment explaining why this is problematic
describe('ComponentName', () => {
test('demonstrates antipattern', () => {
// Code showing what NOT to do
// Multiple aspects of the problem
expect(something).toBe(wrong);
});
});Good Example
// Comment explaining the correct approach
describe('ComponentName', () => {
// Setup if needed
beforeEach(() => {
// Clean setup
});
test('demonstrates best practice', () => {
// Arrange
const input = prepareTestData();
// Act
const result = functionUnderTest(input);
// Assert
expect(result).toBe(expected);
});
test('handles edge case correctly', () => {
// Additional test showing the pattern
});
});Why
- Benefit 1: Explanation of why this matters
- Benefit 2: Impact on test quality
- Benefit 3: Developer experience improvement
- Benefit 4: Maintenance and debugging advantages
Guidelines:
- Specific guideline or tip
- When to apply this pattern
- What to watch out for
- Tools or libraries that help