grammy-test-demo
v0.1.6
Published
Testing framework for grammY
Downloads
24
Maintainers
Readme
Testing framework for grammY
Install the package in your project
npm install grammy-testUse it inside your tests
import { Context } from "grammy";
import { TestBot, testing } from "grammy-test";
let bot: TestBot<Context>;
beforeEach(() => {
bot = new TestBot<Context>();
bot.use(testing());
});
describe("bot", () => {
it("should reply to a message", async () => {
// Attach message handler to the bot
bot.on("message:text", async (ctx) => {
await ctx.reply("Hello, world!");
});
// Simulate a message from a user
await bot.receive.message("hello");
// Assert that the bot replied with the correct message
bot.assert.reply.exact("Hello, world!");
});
});