vistaprint / grunt-js-test

Grunt plugin to run client-side, mocha unit tests and generate code coverage reports
10 stars 11 forks source link

Remove use of grunt-mocha #15

Closed benhutchins closed 9 years ago

benhutchins commented 9 years ago

Removed the use of the module grunt-mocha, wrapping it's features directly into grunt-js-test.

grunt-mocha is not actively maintained. It's using grunt-lib-phantomjs 0.4, they're on 0.7. grunt-lib-phantomjs is what provides the phantomjs library, this results in the tests running in an old version of phantomjs and not getting all the latest and greatest features.

As part of this minor rewrite, I've also removed the two useless tasks (js-test-server-keepalive and js-test-save). js-test-server-keepalive is now built into js-test-server, and js-test-save is supposed to save the results of a coverage report after grunt-mocha had finished. Since the grunt-mocha task is now wrapped into the js-test task, the js-test-save task could also be wrapped into it. The new tasks/lib/save.js file handles saving the coverage reports.

Other misc cleanups include:

This is all in preparation for adding Selenium support to grunt-js-test using selenium-webdriver or webdriverio. Going to make it so you can decide whether to run your tests in phantomjs or configure a selenium server and run it in browsers such as Chrome, Firefox, IE, Safari, Opera, etc. I'd also like to start the discussion of the better library. It'll be easier to implement support using selenium-webdriver, the official selenium library for Node.js - however, webdriverio supports the full WebDriver Wire Protocol allowing it to also work with https://www.browserstack.com/ and http://testingbot.com/. Once this is completed, grunt-js-test can via a CI and easily run all the tests in multiple browsers, then generate reports.

texclayton commented 9 years ago

This sounds good. I was thinking about Selenium support last week. Also, Karma. I'll try to have this merged by Friday evening.

benhutchins commented 9 years ago

Karma is similar to grunt-js-test in some ways. Not sure they'd work together well, what are your thoughts there?

I remember looking at Karma in depth, and I liked it, but didn't think it work @vistaprint due to the JS-Lib structure, support for <reference> tags, and other VP-specific things. However, grunt-js-test is also easier to get started with, partially because grunt-js-test wraps and includes Mocha and Chai (with is arguably a bad thing as well - I think of it as bad currently, I want to allow this to be replaceable - but when first implementing grunt-js-test, it helped speed things up).

texclayton commented 9 years ago

I was wondering how they might work together. I haven't had a chance to look at Karma in depth, but like you said, they are similar. Selenium support looks like a better ROI right now. Start an Issue about Selenium, please.

texclayton commented 9 years ago

I believe this fixes Issue #3. Probably also partially addresses Issue #2

benhutchins commented 9 years ago

It does fix #3 , will be using the latest release of Mocha and also allows updating Mocha in the future to be easier, you can use npm outdated to look for updates in the future.

As for #2, this is not really solved. If Mocha is changed to a shared dependency it would be, but it'll require a rewrite of the server.js to use require.resolve to get the path of mocha since it may not be apart of grunt-js-test directly. This probably makes sense to do, simply hadn't thought of it. Also want to do the same for Chai and Sinon.