I was deciding on a test framework for Javascript.
There are frameworks but too many options: Unit Testing Frameworks
I'm looking for advise, pros and cons of frameworks so it might help to decide which one to choose.
For JS stuff Coming from Tap/Tape and just recently switched to AVA github.com/sindresorhus/ava It's super fast because it executes tests in parallel. It supports Tap protocol output which allows me to use my test reporters I am familiar with.
For testing React stuff I use shallow rendering facebook.github.io/react/docs/test-utils.html Comparing a string is pretty easy. No need for any browser/headless/webdriver/etc
AVA + ShallowRendering = super fast and good DX (developer experience)
Well there are two big ones that most people are using nowadays : Jasmine and Mocha
Quick story on them :
Conclusion :
Jasmine is great if you want a test framework that has everything bundled. Mocha is great if you want to build a modular personalized test framework that fills your needs.
I usually use Mocha (with chaijs, supertest) for Node.js app and Jasmine for client.
I use mocha on all my current projects. It's flexible, and easy to learn. The only downside I can say is that its slow as test coverage increases. Currently 800+ tests on one of my codebases takes about 2 min to complete which isn't terrible but it can be annoying when tracking down a bug. A lot of that can be mitigated though with careful planning and proper data stubbing etc.
Jasmine
Jasmine is one of the most popular unit testing frameworks. It's widely used, with runners for Python and Ruby too. It's described as "a behavior-driven development framework for testing JavaScript code"
Pros
Cons
QUnit
QUnit is the testing framework used by jQuery. It's created with the intension of easy DOM testing. While Jasmine can be extended with plugins to make DOM testing easier, QUnit comes with build-in functionalities. QUnit does not depend on jQuery or any other library.
Pros
Cons
Mocha
A really powerfull library! It has a huge range of features like browser support, simple async support, including promises, test coverage reporting, highlights slow tests, file watcher support, global variable leak detection and many, many more.
Pros
Cons
Tape
Keep it simple, keep it modular. Tape is great at doing that two things.
tape is a simple TAP-producing test library for node and browsers. The tape API is a small superset of the node core assert module. I haven't got the chance to use tape in a large scale project, but it's definatelly on my 2016 resolutions list. I won't include a Proc/Cons for now. You can check some interesting articles about tape to get a better overview of the framework:
This list is far from complete. There are libraries like Jest, Unit.js, Buster.JS, AVA, as well as spies, mocking and stubs libraries like Sinon.js and JSMockito, that are not currently included in the list. To anyone, generous enough to share with us some insights and impressions of the libraries/frameworks not listed, I will gladly add it to the list.