Testing
How the bot is tested — bun:test, Sinon, and module mocking.
Tests use bun:test with Sinon, configured in
apps/discord/bunfig.toml. Test files live in apps/discord/tests/, mirroring
src/, and use the .test.ts suffix.
Running tests
bun run test # whole workspace, via Turborepo
bun run test:coverage # with a coverage reportRun just the bot's suite from its package:
bun --filter @fluffboost/discord testPatterns
- Module mocking —
mock.module()frombun:testreplaces imports at load time, so dependencies like the database and logger are swapped for fakes. - Time control — schedule-sensitive tests use
sinon.useFakeTimers()to pindayjs()to a fixed moment. - Shared fakes —
tests/helpers.tsprovides factories (mockLogger,mockDb,mockInteraction,mockClient,mockEnv, and friends) so each test stays short.
Because commands and jobs are isolated behind these mocks, tests never touch a real database, Redis, or the Discord API.
In CI
GitHub Actions runs the test suite with coverage, an ESLint check, a TypeScript
type check, a dependency audit, and a Docker build test on every push and PR to
main and dev.