Test Organization

Test file structure and naming conventions for the music-app project.

majiayu000 Updated 567 repo stars

File contents

Test Organization Skill

Purpose

Test file structure and naming conventions for the music-app project.

File Structure

src/
├── components/
│   ├── NavBar.jsx
│   └── __tests__/
│       └── NavBar.test.jsx
├── services/
│   ├── tunesService.js
│   └── __tests__/
│       └── tunesService.test.js

Naming Conventions

  • Component tests: ComponentName.test.jsx
  • Service tests: serviceName.test.js
  • Test directory: __tests__/ adjacent to source

Test Structure

describe('ComponentName', () => {
  beforeEach(() => {
    jest.clearAllMocks();
  });

  describe('feature group', () => {
    test('specific behavior', () => {
      // Arrange
      // Act
      // Assert
    });
  });
});

Best Practices

✅ Group related tests with describe ✅ Clear, descriptive test names ✅ One assertion per test (usually) ✅ Clean up in beforeEach/afterEach ❌ Don't skip tests without reason ❌ Don't test implementation details

majiayu000/claude-skill-registry-data/tree/main/data/test-organization commit f2f24bab65

Frequently asked questions

npx skillmds@latest add majiayu000/test-organization