Karma, Sinon, Bard, Chai - ITsvetkoFF/Kv-013 GitHub Wiki
The main purpose of Karma is to make your test-driven development easy, fast, and fun.
Obligatory documentation
When should I use Karma?
- You want to test code in real browsers.
- You want to test code in multiple browsers (desktop, mobile, tablets, etc.).
- You want to execute your tests locally during development.
- You want to execute your tests on a continuous integration server.
- You want to execute your tests on every save.
- You love your terminal.
- You don't want your (testing) life to suck.
- You want to use Istanbul to automagically generate coverage reports.
- You want to use RequireJS for your source files.
Karma is not a testing framework, nor an assertion library. Karma just launches a HTTP server, and generates the test runner HTML file you probably already know from your favourite testing framework. So for testing purposes you can use pretty much anything you like. There are already plugins for most of the common testing frameworks.
##Standalone test spies, stubs and mocks for JavaScript.
No dependencies, works with any unit testing framework.
Obligatory documentation
$ npm install sinon
via NuGet (package manager for Microsoft development platform)
Install-Package SinonJS
or install via git by cloning the repository and including sinon.js in your project, as you would any other third party library.
Don't forget to include the parts of Sinon.JS that you want to use as well (i.e. spy.js).
See the sinon project homepage for documentation on usage.
If you have questions that are not covered by the documentation, please post them to the Sinon.JS mailing list or drop by #sinon.js on irc.freenode.net:6667
###Goals
- No global pollution
- Easy to use
- Require minimal “integration”
- Easy to embed seamlessly with any testing framework
- Easily fake any interface
- Ship with ready-to-use fakes for XMLHttpRequest, timers and more
##bardjs is a small library of functions to help you write Angular v.1.x application tests ... whether you write them in mocha or jasmine or QUnit.
What kind of help? Help with routine tasks that would otherwise clutter your tests and obscure their intent. The poster child in this respect is the inject method. It can easily remove 10 or more lines of boilerplate so you spend less time with setup and more time with your tests. Check it out. The bardjs repo also contains code snippets to make writing tests a little easier. See separate instructions for those below.
Obligatory documentation
Most folks bardjs install it with bower or npm:
bower install bardjs
npm install bardjs
You can also clone bardjs from github and extract bard.jsitself.
bard depends on sinon.js so make sure you have that library available; bower and npm bring that down for you. Almost all of bard is in the bard.js file within the dist folder.
If you're running tests in a browser, add the appropriate script tag below the script for your test framework library:
<script src="/bower_components/bardjs/dist/bard.js"></script> <script src="/npm_modules/bardjs/dist/bard.js"></script>You'll need to add sinon.js as well
<script src="/bower_components/sinon/index.js"></script> <script src="/npm_modules/sinon/lib/sinon.js"></script>Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.
For more information or to download plugins, view the documentation.