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

Extrapolate core functionality #57

Closed jmreidy closed 9 years ago

jmreidy commented 10 years ago

This plugin has matured far beyond its original implementation; it can now run a mocha test suite against Phantom, Sauce Labs, and Selenium, with configuration options for each.

I'm wondering if this plugin should be refactored to remove its grunt dependency. That is to say, remove the core functionality into a moch-integration lib, that can be invoked by this task (via grunt), via a different task runner (gulp-mocha-integration?), or even be used standalone. What do people think? (Especially you, @saadtazi?)

saadtazi commented 10 years ago

Interesting idea.

Maybe we can include some config/options refactoring... For example, the fact that phantom has some specific options and cannot be started like other browsers bothers me. A ghostdriver starter task piped into a webdriver task would make more sense I think.

Also, when trying to have custom reporter for selenium/saucelabs tasks, I didn't find a nice way to reuse existing mocha reporters (because the mocha output would be messed up if concurrency option is > 2). So I had to copy/paste the mocha team-city-reporter and replace console.log() by some array.push() to accumulate the logs... What if we spawn each browser tests in a separate process and read the output and error streams? ...And we fail the task if one of the spawned process fails...

I hope that what I just wrote is "understandable". Those are just ideas off the top of my head.

binarykitchen commented 10 years ago

I'd welcome a gulp plugin. Because there are none, I am (unfortunately) sticking with grunt.

jmreidy commented 10 years ago

@saadtazi

"A ghostdriver starter task piped into a webdriver task would make more sense I think." - This is awesome, but I think would be difficult in a grunt version. (Great gulp use case, though.)

"What if we spawn each browser tests in a separate process and read the output and error streams?" -> Awesome idea. Do you want to take a crack at it? And we can use the branch with those changes as the basis for the grunt/gulp agnostic version.

saadtazi commented 10 years ago

In grunt, we cannot pipe, you are right. But we could have a startGhostdriver task with option {name: 'myPhantomProcess'} and a stopGhostdriver task with the same name option value...Too hackish maybe?

For the 'spawn' refactoring, I can give it a try, but I cannot commit to a date. Super busy at work...

jmreidy commented 10 years ago

@saadtazi Me too, that's why I asked if you wanted to do it :-D

We'll leave this open as a cool thing to do, should we ever get the time. (Or the need to switch to a gulp workflow.)

saadtazi commented 10 years ago

@jmreidy I have an working version of this in a branch: https://github.com/saadtazi/grunt-mocha-webdriver/compare/spawn-process?expand=1 It still needs some "love" and the changes are quite important.

Note that I didn't find a way to keep mocha output colors from the parent process when buffer is required (tried different techniques...), because the child process tty.isatty() is false.

Any comments are welcome...