PROTRACTOR: Integrate jasmine-spec-reporter in slack?

300 Views Asked by At

I installed jasmine-spec-reporter to replace the default DOT reporter.

Everything is great running, but I want to send the texts I'm seeing in the terminal directly to slack. What is the payload that I should send to slack? and is it possible?

3

There are 3 best solutions below

0
Bastien Caudan On

You could use slack-cli to send your test output to slack.

For example, if your test command is jasmine, something like that should do the trick (not tested):

$ jasmine | slackcli -t slack_token -g group_name -c
0
Loucas On

You should do a custom integration from slack incoming webhook app. Copy the webhook url which variants on which channel you want to post the output.

Then in protractor conf.js add the following

 projectName: ' ',
    environment: 'TEST',
    slackUrl: 'https://hooks.slack.com/services/T1J252SLS/',
    channel: '#autotests'
0
Ankesh Pandey On

You could use npm jasmine-slack-reporter package for this.

  1. Before that you should have your slack webHook url. refer this for incoming slack webhook
  2. Finally update your config file like this.

    exports.config = {
      seleniumAddress: "http://localhost:4444/wd/hub",
      specs: ['todo-spec.js'],
      capabilities: {
        browserName: 'chrome',
      },
      onPrepare: function () {
        var webRep = require('jasmine-slack-reporter');
        browser.getProcessedConfig().then(function (config) {
          var browserName = config.capabilities.browserName;
          jasmine.getEnv().addReporter(new webRep.WebReporter({
            projectName: 'Project 1',
            environment: 'Stage',
            slackUrl: "YOUR_WEBHOOK_URL",
            channel: '#dashboard-standup'
          }));
        });
      },
    };