jmreidy / grunt-mocha-webdriver

Grunt task to run Mocha tests against a WebDriver source - either PhantomJS or Sauce Labs
MIT License
36 stars 17 forks source link

[feature request] allow custom reporter when using saucelabs or selenium #54

Closed saadtazi closed 9 years ago

saadtazi commented 10 years ago

The idea is to be able to specify custom reporter when test are run in saucelabs or selenium mode. For example, I would like to create a teamcity reporter, similar to this, but I will probably have to adapt it so it works with grunt-mocha-webdriver:

That team-city reporter doesn't have to live in grunt-mocha-webdriver. Please let me know your preference... I think outside is better...

Once the first one is done, then it would be easy for anyone to create other reporters (jenkins...).

I can give it a try but I would like to have your input first. any thoughts/limitations/concerns?

saadtazi commented 10 years ago

I got it working, it only requires minor changes to mocha-runner.js:

//browserTitle means we're on a SL test
  if (browser.browserTitle) {
    if (!opts.customReporter) { // <--- added an if statement (and a new option)
      // if not phantom and no customReporter is specified
      opts.reporter = generateSauceReporter(browser);
    } else {
      // custom reporter when running
      opts.reporter = require(opts.customReporter)(browser);
    }
  }

I will submit a PR.

jmreidy commented 10 years ago

Hey, sorry for the delay on this. I really like this idea. Awesome work.