A JavaScript project containing standalone javascript widgets based on Bootstrap, jQuery UI and other third-party widgets, styled with LESS.
In the rapid evolving world of Web standards, libraries, and browsers testing is of paramount importance. We need to make sure our widgets continue to function as we upgrade the various libraries that make up our project.
RichWidgets uses jasmine and jasmine-jquery, using karma as our test runner. Widget tests must go beyond simple setup/takedown of the widgets, and must also test all widget options and user interactions. In this way we will be able to keep our widgets both current and stable.
The Karma tool can be easily installed with NPM as:
npm install -g karma
Run all tests on particular browsers:
karma start karma.conf.js --browsers=PhantomJS,Chrome,Firefox
karma start karma.conf.js --single-run=false --auto-watch=true --browsers=Chrome
it
to iit
describe
to ddescribe
debugger;
anywhere in your test to set a breakpoint.--single-run=false --auto-watch=true
options.Tests are configured in two files:
karma.conf.js
- configuration for Karma runnertest/test-main.js
- configuration for Module Loading (AMD)karma.conf.js
test/test-main.js
for the library. If a library
contains more than one file, create a shim for each file. Then create a module that aggregate all library files.In order to run tests on browsers you don't normally have access to, or for purposes of continous integration, we leverage Karma - SauceLabs runner.
In order to set it up locally, you have to setup environmental variables:
export SAUCE_USERNAME=your_username
export SAUCE_ACCESS_KEY=your_generated_access_key
Then you can start one of browsers:
karma start --single-run=false --auto-watch=true --browsers=SL_Firefox_latest
Consult customLaunchers
section in karma.conf.js
for all the configured browsers.