Skip to content
GitHub

createMockUser

variable in meocord/testing Since 4.0.0

const createMockUser: (props?: MockProps<User>) => DeepMocked<User>

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

Use it for the user a command acts on, such as a user option's value, or a message's author.

Examples

TypeScript
import { expect } from 'vitest'

const target = createMockUser()
const interaction = createMockInteraction(ChatInputCommandInteraction, {
  commandName: 'profile',
  options: createChatInputOptions({ target }),
})
expect(interaction.options.getUser('target')).toBe(target)

See also