Pregunta

My team has decided to test our project's (AngularJS) JavaScript code with Mocka via a Grunt task. After some research I found out that you can run Mocka tests either standalone or with the Karma test-runner. As lots of projects seem to prefer Karma I would like to know what the advantage is of using Karma over Mocha standalone. Thanks!

¿Fue útil?

Solución

Mocha standalone is useful for quick testing: see if you're test suites are ok during the development - but you're always running it in NodeJS and not in a real browser. If you want to run them in a browser you have to:
* run it in with Jarsmine
* run it in with a phantomJS integration module
* run it in a web page - manually

Integrating it with Karma let you test your code in a cross-browser environment:
* Check if you use some feature that is not available in some browser
* Quick test for releases: spawn 10 browsers in parallel with tests and check them all at once
* Easy integration with AngularJS, RequireJS, Jenkins, etc...
* Easy code coverage
* Many plugins in general - I.E. Look at karma-ievms or karma-sauce-launcher
* Easy integration with phantomJS
* Preprocess your files before testing them
* And many more features/plugins...

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top