Cypress plugins file not awaiting/asyncing on after:run

Viewed 27

I'm slightly new to cypress and was wondering why this code wasn't working on an after run step of cypress. I ran this code using node on terminal which works fine. However, when i put it within a cypress plugins file with after:run event it doesn't reach the console.log results and doesn't have an error. Any clue?

const{ WebClient} = required('@slack/web-api')
module.exports = {on, config} => {
   on('after:run', (results) => {


      if(results){
         (async () => {
             try{
                let web = new WebClient({slacktoken})
                let result = await web.chat.postMessage({
                    channel: {channel}
                    text: "hello world" 
                })
              console.log(result)
              }
              catch(error){
                  console.log(error)
              }
         })();
      }
   }
}
0 Answers
Related