This guide explains how to run unit tests for this project
Note that this document, the initial setup and configuration of testing, and the initial set of tests for utils/dxClusterFilters.js was created with the help of the AI agent "Claude Code" at https://claude.ai
- Rich Freedman, N2EHL 2026-02-07
npm testnpm run test:runnpm run test:uinpm run test:coverageopenhamclock/
├── src/
│ ├── utils/
│ │ ├── dxClusterFilters.js # Source file
│ │ └── dxClusterFilters.test.js # Test file
│ └── test/
│ └── setup.js # Test setup/configuration
├── vitest.config.js # Vitest configuration
└── package.json # Updated with test scripts
To add more tests, follow this pattern:
import { describe, it, expect } from 'vitest';
import { applyDXFilters } from '../utils/dxClusterFilters.js';
describe('Feature Name', () => {
it('should do something specific', () => {
const spot = {
dxCall: 'W1AW',
spotter: 'K2ABC',
freq: '14.074',
comment: 'FT8',
};
const filters = {
/* your filters */
};
expect(applyDXFilters(spot, filters)).toBe(true);
});
});Add this to your CI pipeline:
# Example GitHub Actions workflow
- name: Run tests
run: npm run test:run
- name: Generate coverage
run: npm run test:coverage
- name: Upload coverage
uses: codecov/codecov-action@v3- Make sure all dependencies are installed:
npm install - Check that Node.js version is 18+ :
node --version
- Ensure file paths use
.jsextensions in imports - Check that
vitest.config.jsis in the project root
- Make sure
@vitest/coverage-v8is installed - Run:
npm install --save-dev @vitest/coverage-v8
- Add tests for other utility files (
callsign.js, etc.) - Add integration tests for React components
- Set up pre-commit hooks to run tests automatically
- Configure coverage thresholds in
vitest.config.js