npm package: @scaffit/jest
Description: Jest unit testing setup with framework-specific configurations for Next.js, React, Vue, Angular, Svelte, Express, Fastify, Node.js projects
Author: Santosh Hanumaiah Ranganatha
Latest version: 1.0.5

# @scaffit/jest

Jest unit testing setup with framework-specific configurations for Next.js, React, Vue, Angular, Svelte, Express, Fastify, Node.js projects.

## Features

- **Framework Detection**: Automatically detects your project framework and configures Jest accordingly
- **TypeScript Support**: Full TypeScript support with ts-jest
- **Coverage Reporting**: Built-in coverage reporting with HTML and LCOV formats
- **Test Setup**: Framework-specific test setup files
- **Mock Utilities**: Pre-configured mock utilities for common scenarios
- **Custom Matchers**: Optional custom Jest matchers
- **ESLint Integration**: Works seamlessly with ESLint

## Supported Frameworks

- Next.js
- React (Vite, Create React App)
- Vue
- Angular
- Svelte
- Express
- Fastify
- Node.js

## Installation

### Option 1: Using Scaffit CLI (Recommended)
```bash
# Add Jest scaffold (no installation needed!)
npx scaffit add jest
```

### Alternative: Global Installation
```bash
# Install CLI globally
npm install -g scaffit

# Add Jest scaffold
scaffit add jest
```

### Option 2: Direct npm package usage
```bash
# Install scaffold directly
npm install @scaffit/jest

# Use in your code
import { setupJest, previewJest } from '@scaffit/jest';

// Setup Jest with custom options
const result = await setupJest({
  includeCoverage: true,
  includeSetupFiles: true,
  features: ['typescript', 'eslint', 'mocks', 'utils'],
  projectRoot: './my-project'
});

// Preview changes before applying
const preview = await previewJest({
  includeCoverage: true,
  features: ['typescript', 'eslint']
});
```

**Note**: Both approaches require `@scaffit/core` to be installed (automatically handled).

## Usage

After installation, you can immediately run tests:

```bash
# Run tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:coverage
```

**Note**: Testing is ready to use immediately after installation.

## Configuration Options

- **Include Coverage**: Enable coverage reporting
- **Include Setup Files**: Create framework-specific test setup files
- **TypeScript Support**: Add TypeScript support with ts-jest
- **ESLint Integration**: Integrate with ESLint
- **Mock Utilities**: Include mock utilities
- **Custom Matchers**: Add custom Jest matchers
- **Test Utilities**: Include test utility functions

## Generated Files

- `jest.config.js` - Jest configuration file
- `test/setup.ts` - Test setup file (if enabled)
- `test/example.test.ts` - Example test file
- `test/utils.ts` - Test utilities (if enabled)
- `test/mocks.ts` - Mock utilities (if enabled)

## Scripts Added

- `test` - Run tests
- `test:watch` - Run tests in watch mode
- `test:coverage` - Run tests with coverage

## Framework-Specific Features

### Next.js
- jsdom environment
- Next.js router mocking
- Image component mocking
- Testing Library integration

### React
- jsdom environment
- Testing Library integration
- User event testing
- Component testing utilities

### Vue
- jsdom environment
- Vue Test Utils integration
- Component testing utilities
- Global test configuration

### Angular
- jsdom environment
- Angular Testing integration
- TestBed configuration
- Component testing utilities

### Svelte
- jsdom environment
- Svelte Testing Library integration
- Store mocking
- Component testing utilities

### Express/Fastify/Node.js
- Node environment
- Request/Response mocking
- API testing utilities
- Server testing helpers

## License

MIT