Skip to content
GitHub

Testing

Inspection

Mocks

  • ChatInputOptions

    The options of a mock slash command, as createChatInputOptions takes them: each value by its option's name.

  • clearAllMocks

    Clears the calls every mock from meocord/testing has recorded, keeping what each was told to do.

  • createChatInputOptions

    Builds a slash command's options from a plain record, found by name as the real options resolver finds them.

  • createDiscordError

    Creates the error discord.js throws for a failed Discord API call, for a mock to reject with.

  • createMock

    Creates a mock of any type, with no class needed, for service doubles and interfaces.

  • createMockChannel

    Creates a mock channel of the given class, such as TextChannel, ThreadChannel or DMChannel.

  • createMockClient

    Creates a mock Client, with users, channels, guilds and application.commands ready to stub.

  • createMockFn

    Creates a mock function that jest's and Vitest's expect both read.

  • createMockGuild

    Creates a mock Guild, with the members, channels, roles and bans managers ready to stub.

  • createMockInteraction

    Creates a mock instance of a discord.js class, such as an interaction, keeping its prototype so instanceof holds.

  • createMockMember

    Creates a mock GuildMember: a user in a server, with the roles given.

  • createMockMessage

    Creates a mock Message that tracks whether it has been deleted.

  • createMockRawMember

    Creates the member Discord sends with an interaction from a server the bot isn't in, as discord.js keeps it.

  • createMockTheme

    Makes a whole theme for a test: MeoCord's defaults with overrides merged over them, frozen.

  • createMockUser

    Creates a mock User: a person, not a bot, with an id of its own.

  • createModalFields

    Builds the fields of a submitted form, as discord.js does when a user submits one.

  • DeepMocked

    A mock of T: every method a mock function, and every nested object mocked in turn, five levels deep, including a discord.js structure that may be absent, such as a message's member, when it is present.

  • isMockFunction

    Tells whether a value is a mock function: one from meocord/testing, jest.fn() or vi.fn().

  • Mock

    A mock function, as jest's Mock and Vitest's Mock name it: the same type as MockedFunction.

  • MockedFunction

    A mock function with the signature of T, and the mock API of MockInstance.

  • MockFnFactory

    A test runner's mock function factory, such as vi.fn.

  • MockGuildOverrides

    What createMockGuild puts in the guild's caches, as the gateway would have filled them.

  • MockInstance

    The mock API of a mock function: what it has recorded, and the methods that change what it does.

  • MockMemberOverrides

    What createMockMember builds a member with.

  • MockMessageOverrides

    What createMockMessage builds a message with.

  • MockProps

    Property values a mock factory sets as it builds the mock.

  • MockRawMemberOverrides

    What createMockRawMember builds a member with: any field Discord sends, with permissions as a permission set and user as the fields of the user given.

  • MockResult

    One call's outcome, as a mock function records it: the value it returned, or the error it threw.

  • MockState

    What a mock function has recorded: each call's arguments, outcome and this, in order.

  • resetAllMocks

    Clears every mock from meocord/testing, and puts each back to the implementation it was created with.

  • RunnerMock

    A mock function a test runner makes, as useMockFn takes it.

  • useMockFn

    Makes every mock meocord/testing creates with the test runner's own mock function, such as Vitest's vi.fn.

  • useStrictMocks

    Has every mock from meocord/testing compute the values discord.js computes, where it reads a placeholder otherwise.

  • withTheme

    Runs fn with theme as the theme of the call, as a handler's call runs.

Module