Automated tests cover the pure modules in src/lib/ — the parsers and the
PDF writer, where the logic actually lives. The chrome.* layer is verified by
hand, because putting a fake extension API around it would test the fake rather
than Chrome.
That split is the reason src/lib/ is forbidden from importing chrome.*.
npm test # all 31 tests
node --test test/pdf.test.js # one file
node --test --test-name-pattern="wrapText" # one case
Node’s built-in runner. No framework, no install, no config.
| File | Tests | Covers |
|---|---|---|
test/youtube.test.js |
12 | URL parsing across every accepted shape, hostname-allowlist rejection, watch-page parsing, the bare-captionTracks fallback, unplayable videos, the parsed flag, regex-literal escaping, track selection precedence |
test/transcript.test.js |
8 | json3 and legacy-XML parsing, empty-body handling, format dispatch, timestamp formatting, paragraph grouping on gaps and length caps, render options |
test/pdf.test.js |
11 | WinAnsi transliteration, word wrap including hard-split of over-long words, PDF structural validity, pagination, escaping, empty input, filename sanitisation |
Meaningful coverage of the important and changed or risky paths, with assertions on behaviour and observable effects. Not a blanket line-percentage mandate — a line-count target rewards tests that execute code without checking it.
Concretely, that means:
src/lib/ has at least one test.cc02654 shipped with one.CI gate: npm run check must pass on Node 20, 22, and 24. There is no coverage
percentage gate, and adding one is not planned.
verifyStructure in test/pdf.test.js is the interesting helper. It parses the
generated bytes back out: header, %%EOF marker, startxref offset, and then
every cross-reference entry, checking that each declared byte offset really does
land on the object it claims. A PDF with a corrupt xref table opens in some
readers and not others, so testing the structure rather than the bytes catches
the failure that matters.
No test covers the extension layer, so run this before any release, and before merging anything that touches the service worker, popup, viewer, or content script.
auto-generated captions.read from transcript panel.?; the print path renders correctly. This is expected.New behaviour in src/lib/ needs a test. New behaviour in the chrome.* layer
needs a line in the PR describing how it was verified, and a step added above if
it is a path worth re-checking every release.