|
1 | | -# Claude Code Sandbox Tests |
| 1 | +# Test Directory Structure |
2 | 2 |
|
3 | | -This directory contains tests for the Claude Code Sandbox project. |
| 3 | +This directory contains all tests for the Claude Code Sandbox project. |
4 | 4 |
|
5 | | -## Test Structure |
| 5 | +## Directory Layout |
6 | 6 |
|
7 | | -- `unit/` - Unit tests for individual components |
8 | | -- `integration/` - Integration tests for testing multiple components together |
9 | | -- `e2e/` - End-to-end tests for testing full workflows |
| 7 | +``` |
| 8 | +test/ |
| 9 | +├── unit/ # Unit tests for individual modules |
| 10 | +├── integration/ # Integration tests for module interactions |
| 11 | +├── e2e/ # End-to-end tests for full workflow scenarios |
| 12 | +├── fixtures/ # Test data, mock responses, sample files |
| 13 | +└── helpers/ # Shared test utilities and helpers |
| 14 | +``` |
10 | 15 |
|
11 | 16 | ## Running Tests |
12 | 17 |
|
13 | 18 | ```bash |
14 | 19 | # Run all tests |
15 | 20 | npm test |
16 | 21 |
|
17 | | -# Run specific test file |
18 | | -npm test test/unit/container.test.js |
| 22 | +# Run tests in watch mode |
| 23 | +npm run test:watch |
| 24 | + |
| 25 | +# Run only unit tests |
| 26 | +npm run test:unit |
| 27 | + |
| 28 | +# Run only integration tests |
| 29 | +npm run test:integration |
| 30 | + |
| 31 | +# Run only E2E tests |
| 32 | +npm run test:e2e |
| 33 | + |
| 34 | +# Run tests with coverage |
| 35 | +npm run test:coverage |
19 | 36 | ``` |
20 | 37 |
|
| 38 | +## Test Naming Conventions |
| 39 | + |
| 40 | +- Unit tests: `*.test.ts` or `*.spec.ts` |
| 41 | +- Test files should mirror the source structure |
| 42 | + - Example: `test/unit/container.test.ts` tests `src/container.ts` |
| 43 | + |
21 | 44 | ## Writing Tests |
22 | 45 |
|
23 | | -Tests should be written using a testing framework like Jest or Mocha. Each test file should be self-contained and test a specific component or feature. |
| 46 | +Tests are written using Jest with TypeScript support. The Jest configuration is in `jest.config.js` at the project root. |
| 47 | + |
| 48 | +### Example Unit Test |
| 49 | + |
| 50 | +```typescript |
| 51 | +import { someFunction } from '../../src/someModule'; |
| 52 | + |
| 53 | +describe('someFunction', () => { |
| 54 | + it('should do something', () => { |
| 55 | + const result = someFunction('input'); |
| 56 | + expect(result).toBe('expected output'); |
| 57 | + }); |
| 58 | +}); |
| 59 | +``` |
| 60 | + |
| 61 | +## E2E Tests |
| 62 | + |
| 63 | +End-to-end tests are located in `test/e2e/` and test the complete workflow of the CLI tool. These tests: |
| 64 | +- Create actual Docker containers |
| 65 | +- Run Claude commands |
| 66 | +- Verify git operations |
| 67 | +- Test the full user experience |
| 68 | + |
| 69 | +Run E2E tests with: `npm run test:e2e` |
0 commit comments