> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mobile-starter.amisi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Testing

> Run unit tests across packages and the mobile app

The project uses **Jest** for unit testing across all packages and the mobile app.

## Running tests

### Run all tests

Run tests across the entire workspace:

```bash theme={null}
bun test
```

### Run package tests

Run tests for all packages only:

```bash theme={null}
bun test:unit:packages
```

### Run mobile app tests

Run tests for the mobile app:

```bash theme={null}
bun test:unit:mobile
```

<Note>
  Mobile tests currently require additional React Native/Expo setup and are skipped by default.
</Note>

### Run tests for a specific package

Run tests for an individual package:

```bash theme={null}
bun test:unit <package>:test
```

**Examples:**

```bash theme={null}
bun test:unit theme:test
bun test:unit config:test
bun test:unit notifications:test
```

## Test configuration

Each package has its own test configuration:

* **`jest.config.ts`** - Package-specific Jest configuration
* **`tsconfig.spec.json`** - TypeScript configuration for test files
* **Root `jest.preset.js`** - Shared Jest configuration for all packages

## Writing tests

### Test file naming

Test files should use one of these extensions:

* `.test.ts` - TypeScript tests
* `.spec.ts` - TypeScript spec files
* `.test.tsx` - React component tests
* `.spec.tsx` - React component spec files

### Test file location

Place test files next to the code they test:

```
packages/theme/src/
  lib/
    theme.ts
    theme.test.ts  ← Test file
```

### Example test

```typescript theme={null}
import { amisiConfig } from './config';

describe('config', () => {
  it('should export valid config', () => {
    expect(amisiConfig).toBeDefined();
    expect(amisiConfig.branding).toBeDefined();
    expect(amisiConfig.theme).toBeDefined();
  });
});
```

## Coverage reports

Test coverage reports are generated in:

```
coverage/packages/<package-name>/
```

To view coverage, run tests and open the generated HTML report:

```bash theme={null}
bun test:unit <package>:test
open coverage/packages/<package-name>/lcov-report/index.html
```

## Continuous integration

The `verify` script runs linting, type checking, and tests on affected projects:

```bash theme={null}
bun verify
```

This is used in CI to ensure code quality before merging.
