Skip to content

Mocking Discord JS for Unit Testing #3576

Description

@Olian04

Seeing as the original issue (#727) was closed over a year ago (with no real conclusion to the issue), and unit testing is still a hassle to implement, I'm opening this issue.

Describe the ideal solution

The ideal solution would be for snippets like the one below to simply work:

import {Guild, TextChannel, Message} from 'discord.js';
import {MockClient} from 'discord.js/mock';
const client = new MockClient();
const guild = new Guild(client, {});
const channel =  new TextChannel(guild, {});
const msg = new Message(channel, {}, client);

msg.awaitReactions(r => r.emoji.name === '👍').then(() => {
  console.log('Thumbs up!');
});
msg.react('👍');

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions