Testing
Every change comes with tests, and every bug fix with a regression test.
| Layer | Command | What it proves |
|---|---|---|
| Unit | pnpm test |
Hashing, normaliser, redaction, histograms, queue, schema rules |
| Property-based | (part of pnpm test, with fast-check) |
The queue never exceeds capacity; redaction catches token shapes |
| Adapter | pnpm --filter @shardlens/discordjs test |
Real discord.js Client with raw payloads: each event is recorded, nothing throws |
| Chaos | (part of the adapter tests) | Collector down, slow, 500, 429 or killed mid-flush: the bot still answers, memory stays capped, no duplicates |
| Integration | pnpm --filter @shardlens/collector test:int |
Real PostgreSQL 16 and 17 (Testcontainers): ingest, rollups, salts, retention, auth on every route |
| End to end | pnpm --filter @shardlens/dashboard test:e2e |
A real collector with seeded data: every dashboard page with axe (WCAG 2.1 AA and best practices, light and dark), XSS-safe rendering, CSP, sign-in and sign-out, ended sessions, error states, unknown commands, keyboard focus, browser locale, server list state, failing commands on a server’s page, admin gating, audit mode and its links to failed runs |
| Benchmark | pnpm --filter @shardlens/discordjs bench |
SDK CPU and memory overhead against the targets |
| Simulated installs | pnpm sim |
The packed packages, installed with npm into four bots that coding agents set up (one of them sharded) and run against a fake Discord: exact counts, no leaked IDs, names, tokens or typed text, clean shutdown (weekly, see tests/sim/README.md) |
| Docs | pnpm --filter @shardlens/docs build |
Code samples compile; no broken links |
Integration, end-to-end and simulated-install tests need Docker. Before the first end-to-end run, install the browser
with pnpm --filter @shardlens/dashboard exec playwright install chromium.
One package at a time
Section titled “One package at a time”pnpm --filter @shardlens/core testpnpm --filter @shardlens/core test -- --watchPublic API changes
Section titled “Public API changes”The public API of each published package is tracked in an API report. After changing it on purpose:
pnpm apiand commit the updated report with your change.