- url - String
Webhook url of your bot.
Default value:http://127.0.0.1:3000/secret-path
- axios - Object
Config/option of Axios.
Default value:{headers: {'content-type': 'application/json'}, method: 'POST'}
- port - Number
Server emulator port.
Default value:2000
- token - String
Bot token.
Default value:ABCD:1234567890
- setBot({params})
- setUser({params})
- setChat({params})
- setMessage({params})
- setInlineQuery({params})
- setCallbackQuery({params})
- setUpdateId(id: Number)
Update id.
Default value: Start in0
- getUser()
- getChat()
- getMessage()
- getInlineQuery()
- getCallbackQuery()
- getUpdateId()
- getWebhook()
- getAllowedUpdates()
Return request of axios or false
in updates ignored.
- sendUpdate({params})
- sendMessage({params})
- sendMessageWithText(text: String, {params})
- sendInlineQuery(query: String, {params})
- sendCallbackQuery({params})
- sendCallbackQueryWithData(data: String, {params})
Telegram Bot Api Server Emulator. Start with startServer()
.
- startServer() - Return Express App Object
Support methods:
You create a test suite with Mocha and ExpectJS.
Example test.js
:
const expect = require('expect.js')
describe('bot', function() {
it('/ping', async function() {
var r = await test.sendMessageWithText('/ping')
expect(r.data.text).to.be.a('string')
expect(r.data.text).to.contain('Pong!')
})
})
Run with $ mocha --exit --timeout 100000
Set environment variables DEBUG=telgraf:test
.