Skip to content
GitHub

useStrictMocks

function in meocord/testing Since 4.2.0

useStrictMocks(): void

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

Call it once in the test runner's setup file. A message's editable, deletable, pinnable, crosspostable, bulkDeletable, hasThread and partial, a member's manageable, kickable, bannable and moderatable, a role's editable, a channel's and a thread's viewable, manageable, deletable, joinable and the rest, and partial on users, channels and reactions then run discord.js's own getters against the mock, and message.thread is null when the channel caches no thread under the message's id. No placeholder warning is logged.

Throws

  • Error when a mock already exists, which was made without it.

Examples

TypeScript
// vitest.setup.ts
useStrictMocks()