Skip to content

Do you write tests for your bots? Then how? #1064

Discussion options

You must be logged in to vote

In case this is some help for you.

I'm still at the begining of my testing learning career, and starting with PEST so what I'm doing might not be proper. But in general, I've found I can test what gets sent to my bot for delivery to a user.

Here's an example of one of my tests at the moment.

it('should notify admin if retrieving a flight duty statistics fails', function () {
    $user = User::factory()->create(['telegram_id' => 987654321]);
    $botMock = Mockery::mock(Bot::class)->expects('sendMessage')->with(Mockery::capture($params))->getMock();
    Telegram::shouldReceive(['bot' => $botMock]);

    //Doing some action that will send a message or photo or whatever at some stage during …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by pavel-mironchik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants