-
Notifications
You must be signed in to change notification settings - Fork 2
Testing
temi edited this page Jul 29, 2015
·
1 revision
- Navigate to the root directory of the profile-hub project
- Execute the following:
brew install node.js
npm install karma
npm install karma-jasmine karma-chrome-launcher --save-dev
npm install -g karma-cli
npm install karma-coverage
- Install other optional browser launchers:
npm install karma-firefox-launcher
npm install karma-safari-launcher
npm install karma-ie-launcher
- Update the
browsers: ['Chrome']
property in karma.conf.js to add additional browsers to test against.
- The source repository contains a karma.conf.js file: this is configures the Karma test runner
- (Optional) Install the IntelliJ Karma test runner:
- Preferences -> Plugins -> Search for Karma -> Install (at the time of writing there was only 1 matching plugin)
- Create a run configuration:
- Run -> Edit Configurations -> New -> Karma
- Give it a name
- Select the karma.conf.js file from the root of the project directory as the Configuration File
- The other default values are fine.
The karma.conf.js file contains a list of all Javascript resources required for testing in the files
list. If you create a new file, you must update the karma.conf.js file or your tests won't work.
// list of files / patterns to load in the browser
files: [
'web-app/js/thirdparty/angular-1.3.13.min.js',
'web-app/js/thirdparty/angular-mocks-1.3.13.js',
'web-app/js/thirdparty/ui-bootstrap-tpls-0.12.0.js',
'web-app/js/angular/profiles.js',
'web-app/js/angular/utils/*.js',
'web-app/js/angular/services/*.js',
'web-app/js/angular/controllers/*.js',
'test/js/specs/**/*.js'
],
The order is important!
Jasmine tests live in the tests/js/specs/
directory. Update existing files or add new ones as necessary.
You can see a code coverage report for the javascript files by following these steps:
- Command Line
- Run
karma start
- Open
coverage/<browser>/index.html
- Run
- IntelliJ
- Run the karma configuration using the
Run 'karma' with Coverage
option (the 3rd toolbar button after the run dropdown). - Open
coverage/<browser>/index.html
- IntelliJ will also annotate the filenames in the project explorer with a percentage of lines covered.
- Run the karma configuration using the