Skip to content

CIRCE / DOCUMENTATION

Testing

Run handlers through the real routing path with fabricated interactions and no Discord connection.

Documentation menu
On this page

The harness

@sxnnyside/circe/testing runs a handler end to end with a synthetic interaction. No gateway, no network.

import { testCommand } from "@sxnnyside/circe/testing";
import ping from "../src/commands/ping";

test("replies with Pong", async () => {
  const result = await testCommand(ping, { commandName: "ping" });
  expect(result.hasReply()).toBe(true);
});

Helpers

Helper Runs
testCommand A slash command.
testComponent A button or select menu, including values.
testModal A modal submit.
testContextMenu A user or message command.
testAutocomplete An autocomplete handler; assert with hasChoice().
testGuard A guard in isolation, e.g. testGuard(guildOnly(), { guild: null }).
createTestInteraction A fabricated interaction with typed option getters.

Results expose reply, followUp, hasReply(), hasEphemeralReply(), hasFollowUp(), hasModal(), hasLog(), isDeferred and isReplied. Option getters enforce required options, and deferReply, editReply, deleteReply and showModal simulate the full lifecycle.

Stub builders createMockUser, createMockMember, createMockGuild, createMockChannel and createMockMessage accept overrides.