When comparing Mocha vs Bower, the Slant community recommends Mocha for most people. In the question“What are the best tools for front-end JavaScript development?” Mocha is ranked 2nd while Bower is ranked 8th. The most important reason people chose Mocha is:
Mocha runs independently from the [assertion library](http://visionmedia.github.io/mocha/#assertions), so you can choose which assertion format works best for you. Mocha most often is run in combination with assertion library [Chai](http://chaijs.com).
Ranked in these QuestionsQuestion Ranking
Pros
Pro Supports different assertion libraries
Mocha runs independently from the assertion library, so you can choose which assertion format works best for you.
Mocha most often is run in combination with assertion library Chai.
Pro Write tests with Behavior Driven Development (BDD)
Allows developers to choose their development process. Not only TDD but also BDD.
Pro Runs in Node.js and the browser
Mocha has a browser build as well as a node command line program so you can test in client and server side environments.
Pro Makes Asynchronous testing extremely easy
No need to write tricky statements for Async testing. Mocha gives you a done
callback. Place this done
parameter in your callback function, that'll let Mocha know that you've written an asynchronous function.
Pro Integrates really well with NodeJS
The Mocha test framework itself runs on NodeJS, hence it makes everything related to it extremely simple. With Mocha's simple syntax and speed, testing your node.js app just got a whole lot easier.
Pro Custom full color test reporters
Mocha has multiple test reporters built in and you can create your own as well. The test reporters have full color and makes it easy to see if your tests fail or not.
Pro Easy to add support for Generators
Aside from the numerous benefits with generators in your application, You can now also integrate generators into your test suite. By using mocha, all you have to do is enable support for generators.
Pro Manages non-JavaScript components
Bower is flexible enough that you can manage pretty much any package you would need on the front-end, so you can manage all your dependencies with one tool, including CSS, boilerplate, fonts and more.
Pro Simplicity provides more flexibility
Bower doesn't try to handle too much of the workflow process, which means it's more flexible, and can be incorporated into more workflows. It tries to just do package management well and nothing else, which is why so many workflow wrappers support it. Because it doesn't try to do too much vertical integration, it also means that the list of supported components that it manages is huge.
Pro Largest front-end specific package registry
Although npm is the largest javascript package manager, Bower is the most popular one built specifically for the front-end. With over 16000 components in its registry, pretty much every component you can think of is supported.
Pro Easily integrates with other tools
Because of Bower's focus on simplicity, it makes it much easier to integrate with other tools, so it has a wide range of support with workflow wrappers and task managers such as yeoman and grunt.
Pro Requires a flat dependency tree
While nested dependencies are better for backend modules that need lots of inter-dependency, they lead to bloated file sizes. Flat dependencies are better for frontend optimization, where file size needs to be more closely managed.
Pro Does not store components in a registry
You always get package directly from owner's repository, i.e. you will always get latest version as soon as its version tag is committed without need of waiting until owner publishes updated package.
Pro Simpler to manage varied code
Because Bower makes few assumptions about the source and format of packages, it's easier to apply it to more of your packages
Pro AMD & CJS compatible
Bower strives to be as simple of a package manager as possible and puts as few restrictions on the packages in the registry as possible, making it the most flexible package manager with the most potential packages.
Cons
Con Can be intimidating for beginners
While some testing frameworks are complete out of the box, Mocha requires developers to select and set up assertion libraries and mocking utilities. For someone who is just starting to learn how to build tests this can be scary as they will also have to choose which libraries to use and learn them too.
Con No atomic tests
Tests cannot be ran in random order.
Con Seems like a redundant package manger
NPM with Webpack/Browserify can handle all the dependencies for both back-end and front-end. The only place where Bower may be useful is for projects which use libraries not supported by NPM, such as Polymer.
Con Deprecated
As of May 2017 Bower has been deprecated and will not receive any updates with new features. Bugs will still be fixed though for existing projects that use Bower.
Con Does not store components in a registry
Bower installs components directly from urls and repositories, which makes it more susceptible to components being taken down, with fewer guarantees about their availability.
Con Difficult to create bundles
To create a minified bundle of all the required JS dependencies other tools need to be used.
For example a JavaScript task runner which will automatically concatenate JavaScript files and minify them will be needed. Although it's done automatically, it's still extra work because the task runner needs to be configured.
Con Lack of signing of packages on the repository
Anyone can register their package on Bower's GIT registry - on one side, this brings a lot of ease to developers, but on the other hand, this can lead to security issues because the packages are not signed.
Con Less packages than npm due to a smaller ecosystem
- Bower: 36,000 packages
- Npm: 161,876 total packages (of course, many work only on the server)