Testing Best Practices

Guidelines for writing effective tests

Willayam Updated

File contents

Testing Best Practices

Unit Tests

  • Test one thing per test
  • Use descriptive test names
  • Arrange-Act-Assert pattern
  • Mock external dependencies

Integration Tests

  • Test component interactions
  • Use realistic test data
  • Clean up after tests

Example Test Structure

describe('UserService', () => {
  it('should create a user with valid data', async () => {
    // Arrange
    const userData = { name: 'Test', email: 'test@example.com' };
    
    // Act
    const user = await userService.create(userData);
    
    // Assert
    expect(user.name).toBe('Test');
  });
});

Willayam/skillkeep/tree/main/fixtures/skills/testing commit 612730bd1f

Frequently asked questions

npx skillmds@latest add willayam/testing-best-practices