Skip to content

grammY TestingProduction-grade testing for Telegram bots

Drive your real bot in-process. Capture every API call. Assert on replies โ€” no tokens, no network, no waiting.

grammY Testing logo

Quick look โ€‹

ts
import { prepareBot } from 'grammy-testing';
import { Bot } from 'grammy';
import { describe, expect, it } from 'vitest';

const bot = new Bot('token');
bot.command('start', (ctx) => ctx.reply('Hello!'));

it('replies to /start', async () => {
  const { chats } = await prepareBot(bot);
  const user = chats.newUser();

  await user.sendCommand('/start');

  expect(user.replies.lastOrThrow().text).toBe('Hello!');
});

Install โ€‹

sh
npm install --save-dev grammy-testing
sh
yarn add --dev grammy-testing
sh
pnpm add --save-dev grammy-testing
ts
import { prepareBot } from 'npm:grammy-testing';

Released under the MIT License.