-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Description
We want to develop a modern, automated testing framework for our Discord bot (OpenSDB), inspired by the idea behind https://github.com/cordejs/corde)](https://github.com/cordejs/corde but tailored to our current stack and requirements.
Existing solutions like corde are a bit outdated and don’t fully match our architecture.
Our goal is to build our own testing layer that keeps the simple, declarative test style of corde, while adding:
- better Discord.js support (current version)
- integration with our MongoDB models
- CI/CD support (GitHub Actions)
- security- and permission-focused tests.
The framework should simulate a Discord environment, trigger commands and interactions, verify bot responses, and check database side effects — all before new changes go live.
Expected Behavior
-
Provide a simple, corde-like DSL for writing tests:
const { group, test, command, beforeStart, afterAll } = require("@opensdb/test"); const { client, loginBot } = require(".."); beforeStart(async () => { await loginBot(); }); group("main commands", () => { test("ping command must return... Ping?!!", () => { expect("ping").toReturn("Ping?"); }); }); afterAll(() => { client.destroy(); });
-
Support for simulating Discord events:
- text commands / slash commands
- button & select menu interactions
- modals and other interaction types.
-
Allow mocking of:
- guilds, channels, members, roles
- database calls (MongoDB models)
- external services (APIs, webhooks).
-
Tests should run:
- locally via
npm run test:bot - automatically in GitHub Actions on PRs.
- locally via
-
Clear, readable output with which group/test failed and why.
-
Optional snapshot testing for embeds and complex messages.
Example Test Scenario
group("verification", () => {
test("`/verify` with valid data creates a VerifiedUser", async () => {
const user = createMockUser({ roles: ["unverified"] });
await command("/verify", {
user,
args: { studentId: "123456" },
});
expectReply(user).toContain("You are now verified!");
expectDatabase("VerifiedUser").toContain({ discordId: user.id });
});
});Additional Notes
-
Reference / Inspiration:
- Main inspiration is the corde project: https://github.com/cordejs/corde
We keep the feel of corde’s API but re-implement it with up-to-date dependencies and our own features.
- Main inspiration is the corde project: https://github.com/cordejs/corde
-
Must work fully offline (no real Discord API calls) using mocks and stubs.
-
Should be modular so we can later add:
- permission matrix tests
- rate-limit / flood simulations
- regression suites for critical commands (verification, warnings, admin tools).
-
Final goal: High test coverage for all critical OpenSDB features so every release can be validated automatically before deployment.