Tests are implemented using Vitest. To run the tests, use the following commands:
# Run tests once
npm test
# Run tests in watch mode (useful during development)
npm run test:watch
# Run tests with coverage report
npm run test:coverageEach test file corresponds to a module. For example:
get-process-type.test.tstests the functionality inget-process-type.ts
When adding new tests:
- Create a new test file with the
.test.tsextension in the tests directory - Import the necessary testing utilities from Vitest
- Import the functions to test from the parent directory
- Write your tests using the
describe,it, andexpectfunctions
For functions that rely on external dependencies or environment variables, use Vitest's mocking capabilities.
Example:
import { describe, it, expect, vi } from 'vitest';
// Mock a module
vi.mock('module-name', () => {
return {
functionName: vi.fn()
};
});