This document provides information about running and maintaining tests for the Stellar Wrap project.
We use Lighthouse CI to track Performance, Accessibility, Best Practices, and SEO scores on every pull request.
| Category | Minimum Score | Enforcement |
|---|---|---|
| Performance | 70 | Hard fail (PR blocked) |
| Accessibility | 85 | Hard fail (PR blocked) |
| Best Practices | 90 | Hard fail (PR blocked) |
| SEO | 80 | Hard fail (PR blocked) |
Useful for debugging performance regressions before opening a PR:
# 1. Install dependencies (if not already done)
yarn install
# 2. Build the production app
yarn build
# 3. Run Lighthouse CI against the local production server
yarn lhci:local
## Quick Start
```bash
# Install dependencies (if not already done)
npm install
# Run all tests
npm test
# Run tests in watch mode (for development)
npm run test:watch
# Generate coverage report
npm run test:coverage- Jest - JavaScript testing framework
- TypeScript - Type-safe test code
- Next.js Jest Integration - Configured for Next.js 16
jest.config.js- Main Jest configurationjest.setup.js- Global test setup and utilities
src/services/
├── indexer/
│ ├── __tests__/
│ │ └── indexer.service.test.ts
│ └── types.ts
├── achievement/
│ ├── __tests__/
│ │ └── achievement-calculator.test.ts
│ └── types.ts
└── __tests__/
├── test-utils.ts
├── fixtures.ts
└── README.md
npm testWatch mode automatically re-runs tests when files change:
npm run test:watchnpm test -- indexer.service.test.tsnpm test -- --testNamePattern="calculateVolume"Share card screenshots are tested with Playwright at the card's native
1080x1080 resolution. The suite covers all five color themes, short and long
persona names, transaction counts of 1, 100, and 999,999, and missing
archetype/vibe data.
# Run visual comparisons against committed baselines
npm run test:visual
# Update baselines after an intentional ShareImageCard visual change
npm run test:visual:updateReview the generated image changes before committing updated baselines. Visual
tests fail when the screenshot diff exceeds 0.1%.
npm run test:coverageCoverage reports are generated in the coverage/ directory. Open coverage/lcov-report/index.html in a browser to view the detailed report.
- Target: 80%+ coverage for all services
- Areas to Cover:
- All public methods
- Edge cases
- Error handling
- Boundary conditions
- Integration scenarios
describe('ServiceName', () => {
beforeEach(() => {
// Setup before each test
});
describe('methodName', () => {
it('should do something specific', () => {
// Test implementation
});
});
});import { createMockTransaction } from '../__tests__/test-utils';
import { XLM_PAYMENT_TRANSACTIONS } from '../__tests__/fixtures';
// Use utilities to create test data
const transaction = createMockTransaction({ hash: '0x123' });
// Use fixtures for common scenarios
const result = service.processTransactions(XLM_PAYMENT_TRANSACTIONS);- Isolation: Each test should be independent
- Descriptive Names: Test names should clearly describe what is being tested
- Arrange-Act-Assert: Structure tests with clear sections
- Edge Cases: Test boundary conditions and error cases
- Mocking: Use mocks for external dependencies
- Fixtures: Reuse test data fixtures when possible
Test individual functions and methods in isolation.
Location: src/services/**/__tests__/*.test.ts
Test how multiple components work together.
Location: src/services/**/__tests__/*.integration.test.ts (to be added)
Tests should run automatically in CI/CD pipelines. Ensure:
- Tests pass before merging PRs
- Coverage thresholds are maintained
- All new code includes corresponding tests
- Ensure dependencies are installed:
npm install - Check Jest configuration in
jest.config.js - Verify test file naming matches patterns in
jest.config.js
- Ensure TypeScript is properly configured
- Check
tsconfig.jsonincludes test files - Verify type definitions are imported correctly
- Check
collectCoverageFrominjest.config.js - Ensure test files are not included in coverage
- Verify coverage thresholds are realistic
To make tests pass:
- Implement the indexer service (issue #34)
- Implement the achievement calculator service (issue #40)
- Initialize services in test
beforeEachhooks - Remove placeholder comments and TODOs