dimanche 6 mars 2016

A guide to a clean test environment for javascript

I gave up on setting up my test environment. It is such a pain. I was installing around 30 different npm packages (karma, gulp-karma, karma-mocha, karma-jasmine--runner-reporter, ...). It was just so ridiculous.

First I tried it with Karma + Mocha but I just couldn't setup a nice reporter for it. I only received those:

[19:10:31] Starting 'tests'...
06 03 2016 19:10:31.387:WARN [karma]: Port 9876 in use
06 03 2016 19:10:31.389:WARN [karma]: Port 9877 in use
06 03 2016 19:10:31.390:INFO [karma]: Karma v0.13.21 server started at http://localhost:9878/
06 03 2016 19:10:31.394:INFO [launcher]: Starting browser PhantomJS
06 03 2016 19:10:32.902:INFO [PhantomJS 2.1.1 (Windows 8 0.0.0)]: Connected on socket /#5NYYU1NH9PvdIqijAAAA with id 75452011
PhantomJS 2.1.1 (Windows 8 0.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
PhantomJS 2.1.1 (Windows 8 0.0.0): Executed 1 of 1 SUCCESS (0 secs / 0.001 secs)
PhantomJS 2.1.1 (Windows 8 0.0.0): Executed 1 of 1 SUCCESS (0.007 secs / 0.001 secs)
[19:10:32] Finished 'tests' after 1.7 s

Process finished with exit code 0

And these are simply ugly and not informative. None of those describe strings appeared etc. Then I tried jasmine and just needed to start over again. Configuration over configuration.

I just don't understand why isn't there one big bundle which you can install - short! configure and launch.

My Question

Can anybody provide me with a receipt with the following ingredigents:

  • Testing JS Code
  • with PhantomJS
  • and the Mocha Framework
  • and the Mocha "Spec" Reporter!
  • using Gulp Tasks

Please don't think I'm lazy. I really had opened 40 Chrome Tabs filled with "karma config mocha reporter" and "karma reporter setup test failed blabla". I'm just getting crazy with all those NPM stuff.

If you provide me with one working way of setting up my beloved test environment I would be very grateful!

Charlie

Aucun commentaire:

Enregistrer un commentaire