@happyvertical/smrt-vitest
Testing utilities for SMRT objects including fixtures, mocks, test database setup, and custom assertions.
v0.19.0TestingVitest
Overview
smrt-vitest provides testing utilities specifically designed for SMRT objects, including database setup, fixture generation, and custom matchers.
Installation
bash
npm install -D @happyvertical/smrt-vitestQuick Start
typescript
import { describe, it, expect } from 'vitest';
import { createTestDb, createFixture } from '@happyvertical/smrt-vitest';
import { ProfileCollection } from '@happyvertical/smrt-profiles';
describe('Profile Tests', () => {
it('should create profile', async () => {
// Setup test database
const db = await createTestDb();
const profiles = await ProfileCollection.create({ db });
// Create test fixture
const profile = await createFixture(profiles, 'Profile', {
displayName: 'Test User',
email: 'test@example.com'
});
expect(profile.displayName).toBe('Test User');
expect(profile.id).toBeDefined();
});
});Key Features
- Test database setup with automatic cleanup
- Fixture generation for SMRT objects
- Mock implementations for external services
- Custom Vitest matchers for SMRT assertions
- Transaction rollback for test isolation