When comparing Karma vs QUnit, the Slant community recommends Karma for most people. In the question“What are the best JavaScript unit testing tools?” Karma is ranked 4th while QUnit is ranked 6th. The most important reason people chose Karma is:
Do you prefer other test frameworks such as Mocha, Jasmine, qUnit or any other framework? Well you're in luck as Karma can be easiliy be extended to wrap around ANY framework of your choice.
Ranked in these QuestionsQuestion Ranking
Pros
Pro Easily extensible
Do you prefer other test frameworks such as Mocha, Jasmine, qUnit or any other framework? Well you're in luck as Karma can be easiliy be extended to wrap around ANY framework of your choice.
Pro Provides both Browser based testing as well as headless tests
Karma eases out the UI testing process as you can test your code on all your devices let it be smartphones, tablets or your very own desktop. If you don't want all of that, you always have the option of headless testing using a PhantomJS instance.
Pro Provides the option of running client/servers either separately or on the Development computer
These options are really helpful in cases, where you have the luxury of multiple machines (tablets, mobile phones desktops) around you.
Pro You can test your code in cross browser environments
Being able to test your code directly via your testing tool is a breeze! You don't need to download a fancy tool to see how your app looks in a number of different browsers, now that Karma would do the job for you.
Pro Has plugins for WebStorm and is supported by the Netbeans IDE
Thanks to Karma, you won't need to spawn up a new terminal just so that you can test your app, you can now code and test right from the IDE
Pro Tests run in the order they're added to the suite
In cases where you want (I know your test cases must be atomic) where you really really want your test cases to run in a specific order, maybe if the current one rely on those of previous case, you can use Qunit by setting QUnit.config.reorder = false and your test cases will run in the order you've provided.
Pro Works really well if performing DOM Testing
All frontend developers already know the ease that jQuery framework has brought to their lives, in handling DOM events and accessing elements. Since Qunit was built as a part of jquery (is even used by jQuery itself for unit testing) hence it makes testing of DOM elements a lot easier.
Pro Extremely easy to start from scratch
Seriously! All you have to do is include the Qunit library from the CDN, then create your Testcases js file, and RUN IT! . Your outputs would be displayed in a pretty little format in your browser.
Cons
Con No Support for NodeJS testing
Currently Karma doesn't support testing of apps built on NodeJS. So if you have a node app, you don't want to use Karma, Mocha or Jasmine can do the job for you.
Con No plugin for Eclipse (yet)
Do most of your code using Eclipse, well, you're in bad luck. Karma doesn't have an eclipse plugin, though if you are a real die hard eclipse fan, you can see this little hack to be able to run Karma from inside Eclipse Link
(Time of writing: July 2014)
Con Testing of Async operations can be a little tough at times.
Qunit, expects us to call the start() function before the Async function itself, and stop() after it stops. This can be a problem when you have no way of knowing, when your function will start or stop (your testing a number of dependent functions)