Telegraf Test is a simple test toolkit for Telegram bots that emulates the Telegram Bot API server locally, allowing offline testing without network calls. Current stable version is 1.2.1. It works with Telegraf versions below 3 and supports common test frameworks like Mocha. Key differentiators include local server emulation, support for sending messages, inline queries, and callback queries, and offline operation. It uses Axios to send requests to a local webhook endpoint.
npm install telegraf-testNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to set up a Telegraf bot with webhook and test it using TelegrafTest by sending a message and verifying the reply.
Use with Telegraf v2.x or consider upgrading to Telegraf v4+ and finding an alternative test toolkit.
Use require() instead of import.
Specify a different port in options: new TelegrafTest({ port: 3001 })Check for false return value: const res = await test.sendUpdate({...}); if (res === false) { /* handle ignored */ }Use const TelegrafTest = require('telegraf-test');Pass a different port in options: new TelegrafTest({port: 3001})Run: npm install telegraf@2