# Testing signals — trekhleb/javascript-algorithms

> Canonical page: https://codevetter.com/unpack/javascript-algorithms/testing-signals

# Testing signals — trekhleb/javascript-algorithms

Scanned commit 85293e3e2b88f4d2ce330d956b139cf628aa1e82 (2026-07-25). Generated by codevetter codevetter 1.12.0 on 2026-09-22.

Testing is the project's backbone: Jest 30 with ~112 __test__/__tests__ directories and ~178 spec files co-located beside implementations. Coverage thresholds are aspirational-strict (100% statements/functions/lines, 95% branches) but only enforced when the `coverage` script runs — plain `npm test` collects no coverage. Shared tester harnesses (SortTester, FourierTester) standardize whole algorithm families, and CI runs lint + coverage with Codecov upload on Node 22.
- Jest is configured in jest.config.js with testRegex '(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$', node_modules ignored, bail:false, verbose:false, and collectCoverage off by default. — [jest.config.js#L1-30](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/jest.config.js#L1-L30)
- coverageThreshold demands 100% statements/functions/lines and 95% branches globally, but because collectCoverage is false this only bites under `npm run coverage`/`npm run ci`. — [jest.config.js#L10-39](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/jest.config.js#L10-L39) [package.json#L33-34](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/package.json#L33-L34)
- Tests are co-located in `__test__` (singular, the dominant convention, ~112 dirs) or `__tests__` (plural, used by a few newer areas like seam-carving and matrix) directories next to the code they exercise. — [src/data-structures/linked-list/__test__/LinkedList.test.js](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/src/data-structures/linked-list/__test__/LinkedList.test.js) [src/algorithms/image-processing/seam-carving/__tests__/resizeImageWidth.node.js](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/src/algorithms/image-processing/seam-carving/__tests__/resizeImageWidth.node.js)
- SortTester is a shared test harness exporting canned fixtures (sortedArr, reverseArr, notSortedArr, equalArr, negativeArr) plus static methods testSort, testNegativeNumbersSort, testSortWithCustomComparator, testSortStability and testAlgorithmTimeComplexity — the last uses jest.fn() to count visitingCallback invocations as a complexity proxy. — [src/algorithms/sorting/SortTester.js#L1-72](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/src/algorithms/sorting/SortTester.js#L1-L72)
- The seam-carving spec uses a `.node.js` suffix inside a `__tests__` (plural) dir so the testRegex `__tests__/.*` alternative picks it up, and validates output against a reference PNG allowing <=10% of pixels to differ beyond a 50-value color threshold — a fuzzy image-equality assertion, not exact matching. (inferred) — [src/algorithms/image-processing/seam-carving/__tests__/resizeImageWidth.node.js#L58-84](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/src/algorithms/image-processing/seam-carving/__tests__/resizeImageWidth.node.js#L58-L84) [jest.config.js#L22](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/jest.config.js#L22)
- Helper files like src/algorithms/sorting/SortTester.js and src/algorithms/math/fourier-transform/__test__/FourierTester.js are deliberately named so they are NOT matched by testRegex (no .test/.spec suffix, not in a `__tests__` dir) — they exist only to be imported by real specs. (inferred) — [src/algorithms/sorting/SortTester.js](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/src/algorithms/sorting/SortTester.js) [jest.config.js#L22](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/jest.config.js#L22)
- LinkedList.test.js exemplifies the house test style: construct the structure, call mutating methods, and assert primarily on toString() output and head/tail invariants rather than internal state. — [src/data-structures/linked-list/__test__/LinkedList.test.js#L3-60](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/src/data-structures/linked-list/__test__/LinkedList.test.js#L3-L60)
- CI is the only place tests gate merges: the workflow runs `npm run coverage` after lint and uploads results via codecov/codecov-action@v4; the local pre-commit hook runs lint only, so a contributor can commit failing tests locally. — [.github/workflows/CI.yml#L28-35](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/.github/workflows/CI.yml#L28-L35) [.husky/pre-commit](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/.husky/pre-commit)
- The playground has its own spec asserting playground() === 120 (factorial(5)), giving contributors a sandbox that still participates in the coverage run. — [src/playground/__test__/playground.test.js#L1-8](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/src/playground/__test__/playground.test.js#L1-L8) [src/playground/playground.js#L7-10](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/src/playground/playground.js#L7-L10)
- CONTRIBUTING.md codifies the 100% coverage expectation for PRs and asks contributors to run npm run lint and npm test before submitting. — [CONTRIBUTING.md#L3-7](https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/CONTRIBUTING.md#L3-L7)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
