diff --git a/.gitignore b/.gitignore index 059ab83..42665da 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ MANIFEST *.iml *.sqlite3 *.pyc -venv \ No newline at end of file +venv +tests/javascript/reports +tests/javascript/PhantomJS* \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 37302da..61aaaba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,9 +20,10 @@ addons: install: - sudo pip install pylint - sudo pip install -r requirements.txt - - npm install -g jshint + - npm install -g jshint karma jasmine-core karma-phantomjs-launcher karma-coverage karma-junit-reporter karma-jasmine script: - - sonar-scanner - pylint openstack_lease_it/openstack_lease_it openstack_lease_it/lease_it - jshint . + - karma start tests/javascript/karma.conf.ci.js + - sonar-scanner diff --git a/sonar-project.properties b/sonar-project.properties index 5ca09d0..e90e9c8 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -12,3 +12,7 @@ sonar.sources=openstack_lease_it # Exclude static directory sonar.exclusions=openstack_lease_it/lease_it/static/contrib/** + +# SonarJs for javascript coverage +sonar.javascript.lcov.reportPath=tests/javascript/reports/coverage/lcov.info +sonar.surefire.reportsPath=tests/javascript/reports/junit diff --git a/tests/javascript/karma.conf.ci.js b/tests/javascript/karma.conf.ci.js new file mode 100644 index 0000000..b1a027d --- /dev/null +++ b/tests/javascript/karma.conf.ci.js @@ -0,0 +1,26 @@ +var baseConfig = require('./karma.conf.js'); + +module.exports = function (config) { + // Load base config + baseConfig(config); + + // Override base config + config.set({ + singleRun: true, + colors: false, + autoWatch: false, + reporters: ['progress', 'junit', 'coverage'], + preprocessors: { + '../../openstack_lease_it/lease_it/static/js/*.js': ['coverage'] + }, + browsers: ['PhantomJS'], + junitReporter: { + outputFile: 'reports/junit/TESTS-xunit.xml' + }, + coverageReporter: { + type: 'lcov', + dir: 'reports', + subdir: 'coverage' + } + }); +}; \ No newline at end of file diff --git a/tests/javascript/karma.conf.js b/tests/javascript/karma.conf.js new file mode 100644 index 0000000..52aa2a1 --- /dev/null +++ b/tests/javascript/karma.conf.js @@ -0,0 +1,69 @@ +// Karma configuration +// Generated on Sat Apr 29 2017 11:31:54 GMT+0200 (CEST) + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine'], + + + // list of files / patterns to load in the browser + files: [ + '../../openstack_lease_it/lease_it/static/js/*.js' + ], + + + // list of files to exclude + exclude: [ + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + }, + + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['PhantomJS'], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: Infinity + }); +};