Testing helpers at a glance
Every helper meocord/testing exports, how it is called and what it does.
Inspection
| Helper | What it does |
|---|---|
createExecutionContext(controller, methodName, options?) | Builds the |
expectCompleteCatalog(translator, options?) | Checks that every locale translates every message, and throws listing each gap, locale by locale. |
findRouteConflicts(app) | Finds component patterns that rank equally and can match the same |
getResponse(interaction) | Reports how an interaction was answered: where its answer stands, and every answer call it got, in order. |
inspectHandler(controller, methodName, options?) | Reports what runs when a handler is dispatched, and the metadata declared on it, without running anything. |
resolveRoute(app, input) | Resolves which handler a component's |
testCooldownStore(name, factory, framework) | Checks that a |
Mocks
| Helper | What it does |
|---|---|
clearAllMocks() | Clears the calls every mock from |
createChatInputOptions(opts?) | Builds a slash command's options from a plain record, found by name as the real options resolver finds them. |
createDiscordError(code, message?) | Creates the error discord.js throws for a failed Discord API call, for a mock to reject with. |
createMock(props?) | Creates a mock of any type, with no class needed, for service doubles and interfaces. |
createMockChannel(Class, props?) | Creates a mock channel of the given class, such as |
createMockClient() | Creates a mock |
createMockFn(impl?) | Creates a mock function that jest's and Vitest's |
createMockGuild(overrides?) | Creates a mock |
createMockInteraction(Class, props?) createMockInteraction(Class, props) | Creates a mock instance of a discord.js class, such as an interaction, keeping its prototype so |
createMockMember(overrides?) | Creates a mock |
createMockMessage(overrides?) | Creates a mock |
createMockRawMember(overrides?) | Creates the member Discord sends with an interaction from a server the bot isn't in, as discord.js keeps it. |
createMockTheme(...overrides) | Makes a whole theme for a test: MeoCord's defaults with |
createMockUser | Creates a mock |
createModalFields(values) | Builds the |
isMockFunction(fn) | Tells whether a value is a mock function: one from |
resetAllMocks() | Clears every mock from |
useMockFn(factory) | Makes every mock |
useStrictMocks() | Has every mock from |
withTheme(theme, fn) | Runs |
Module
| Helper | What it does |
|---|---|
reportAllStartupErrors() | Has decorators keep the startup errors they find, as a bot built with |