No test harness today. Two small, high-leverage targets to start with:
-
EventBuilder (src/content/11-event-builder.js) — every event kind the extension emits has a deterministic tag shape. Round-trip each builder against a golden JSON fixture, so accidental changes to tag ordering/casing/kind numbers fail CI instead of polluting relays.
-
Utils.normalizeUrl — the URL metadata service keys on this. If it silently changes, cached events start missing. A table-driven test with ~20 URL pairs (trailing slash, tracking params, scheme, fragment, IDN, …) would catch nearly all regressions.
Approach
- Node test runner (
node --test) — no dependency to add.
- Extract the tested modules into something loadable by Node. The content scripts' top-level-
var pattern doesn't cooperate with require/import; easiest workaround is a small test/loader.js that reads the file, evals in a sandbox, and returns the declared global. Or switch the modules to a conditional export (if (typeof module === 'object') module.exports = Foo). Pick one approach in the implementing PR and stick to it.
No test harness today. Two small, high-leverage targets to start with:
EventBuilder(src/content/11-event-builder.js) — every event kind the extension emits has a deterministic tag shape. Round-trip each builder against a golden JSON fixture, so accidental changes to tag ordering/casing/kind numbers fail CI instead of polluting relays.Utils.normalizeUrl— the URL metadata service keys on this. If it silently changes, cached events start missing. A table-driven test with ~20 URL pairs (trailing slash, tracking params, scheme, fragment, IDN, …) would catch nearly all regressions.Approach
node --test) — no dependency to add.varpattern doesn't cooperate withrequire/import; easiest workaround is a smalltest/loader.jsthat reads the file, evals in a sandbox, and returns the declared global. Or switch the modules to a conditional export (if (typeof module === 'object') module.exports = Foo). Pick one approach in the implementing PR and stick to it.