Automated testing of discord.js bots

Viewed 1029

I've been working on creating discord bots using discord.js, and they've gotten large enough that I'd like to be able to set up automated testing for them - I've found this library (corde), but as it doesn't seem to be widely used, I'd like to see if there are other, more mature options available out there first.

Any help would be greatly appreciated. Manually testing bot commands one at a time is growing somewhat tiring.

1 Answers

If you read some of the examples in the github repo, you can simply set the prefix of all of your bots as the same (or change the code below) and then as the client logs in, it tests a command.

const { group, test, command, beforeStart, afterAll } = require("corde");
const { client, loginBot } = require("..");

beforeStart(() => {
  loginBot();
});

group("main commands", () => {
  test("Hello command should return... hello!!", () => {
    expect("ping").shouldReturn("Ping?");
  });
});

afterAll(() => {
  client.destroy();
});

There is far more code that will help in the repo, here is the main index.js file if you need more assistance, or you could ask in a comment below.

Related