gratifyguy / botkit-mock

Write tests for Botkit.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Where is "this" coming from in the examples

simonfranzen opened this issue · comments

I tried to setup the botkit-mock and I am a bit confused where "this" comes from

describe("controller tests",()=>{
    beforeEach(()=>{
        this.controller = Botmock({}); // is unndefined

I tried it also to just define controller and bot as variables in the test, but my testbot is still not responding.

Found out that my bot was not responding, because it sent "direct_message" and I was only listening to "message_received".

Anyway: "this" is undefined and I got it working with defining var controller, bot; in my spec and use these variables instead of this.controller and this.bot.

hey @simonfranzen, this.controller you could use it in pair with arrow function where you bind this to function. you could use var controller, bot it works too.

does message_received work as expected?

yes everything works as expected. Just had a few problem to start with your framework :)