Tests
This project uses two separate Jest runners to handle the mixed runtime requirements of Node build scripts and React frontend components.
Contents
- Test runners
- Coverage
- Running tests locally
- Reading the coverage report
- What is tested and what is excluded
- Troubleshooting
- References
Test runners
Two runners are needed because CRA injects its own Babel and CSS transform pipeline; running CRA tests with raw Jest fails to parse CSS and static asset imports.
| Runner | Command | Config | Scope |
|---|---|---|---|
| Node | npm run test:node |
jest.node.config.js |
src/__tests__/ |
| CRA | npm run test:cra |
CRA built-in | src/**/*.test.{js,jsx} |
Combined commands:
| Command | Description |
|---|---|
npm run test:all |
Runs both runners sequentially |
npm run test:ci |
Non-interactive CI mode for both runners |
npm run test:helpers |
Runs only src/__tests__/fetchHelpers |
Coverage
No minimum coverage thresholds are currently enforced. Run npm run test:node -- --coverage to generate a local HTML report and view current percentages.
| Metric | Threshold | How to check |
|---|---|---|
| Statements | Not enforced | npm run test:node -- --coverage |
| Branches | Not enforced | npm run test:node -- --coverage |
| Functions | Not enforced | npm run test:node -- --coverage |
| Lines | Not enforced | npm run test:node -- --coverage |
Coverage is collected from config/jest/**/*.js, src/**/*.{js,jsx}, and scripts/**/*.js.
Running tests locally
- Install dependencies:
npm install - Run the Node runner:
npm run test:node - Run the CRA runner:
npm run test:cra - Run both at once:
npm run test:all - For CI (non-interactive, no watch mode):
npm run test:ci
Reading the coverage report
After running npm run test:node -- --coverage, open coverage/index.html in a browser to see the full line-by-line HTML report. A machine-readable summary is also written to coverage/coverage-summary.json.
What is tested and what is excluded
Tested source locations:
src/**/*.{js,jsx}— React components and hooksscripts/**/*.js— build-time scripts (README parsing, media downloads, postprocessing)config/jest/**/*.js— Jest configuration helpers
Intentionally excluded from coverage:
- Test files (
__tests__/,*.test.js,*.spec.js) - CRA test setup (
setupTests.js) - Standalone debug and audit scripts (
debugRepoDocs.js,audit-check.js)
Troubleshooting
- CSS parsing errors when running raw
jest— usenpm run test:crainstead, which uses CRA's transform pipeline. - Missing
fetchin Node tests — confirm thatnode-fetchv2 is installed as a devDependency (npm install --save-dev node-fetch@2).