From dca0f6b36622162286f8a880e0ae73d509e53825 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lievremont Date: Thu, 20 Mar 2014 16:27:16 +0100 Subject: Run JS tests on maven test phase --- sonar-server/Gruntfile.coffee | 7 +++++++ sonar-server/karma.conf.js | 6 +++--- sonar-server/package.json | 6 ++---- sonar-server/pom.xml | 10 ++++++++++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/sonar-server/Gruntfile.coffee b/sonar-server/Gruntfile.coffee index 82177d73582..c7700324e70 100644 --- a/sonar-server/Gruntfile.coffee +++ b/sonar-server/Gruntfile.coffee @@ -1,4 +1,5 @@ module.exports = (grunt) -> + grunt.loadNpmTasks('grunt-karma'); grunt.initConfig pkg: grunt.file.readJSON('package.json') @@ -178,6 +179,12 @@ module.exports = (grunt) -> ] + karma: + unit: + configFile: 'karma.conf.js' + singleRun: true + + watch: options: spawn: false diff --git a/sonar-server/karma.conf.js b/sonar-server/karma.conf.js index 09d37706938..de6a2a042a2 100644 --- a/sonar-server/karma.conf.js +++ b/sonar-server/karma.conf.js @@ -14,7 +14,7 @@ module.exports = function(config) { config.set({ // base path, that will be used to resolve files and exclude - basePath: 'src/main/webapp/javascripts', + basePath: 'src/main/webapp/js', // frameworks to use @@ -26,7 +26,7 @@ module.exports = function(config) { // dependencies 'third-party/jquery.js', 'third-party/underscore.js', - 'third-party/require.js', + 'require.js', 'translate.js', 'common/inputs.js', @@ -76,7 +76,7 @@ module.exports = function(config) { coverageReporter: { - type : 'text', + type : 'lcovonly', dir : '../../../../target/karma/coverage/' }, diff --git a/sonar-server/package.json b/sonar-server/package.json index e6c05471709..2c134ac257e 100644 --- a/sonar-server/package.json +++ b/sonar-server/package.json @@ -14,13 +14,11 @@ "grunt-contrib-handlebars": "^0.7.0", "grunt-contrib-requirejs": "^0.4.3", "grunt-contrib-watch": "~0.5.3", - "grunt-contrib-uglify": "^0.4.0" + "grunt-contrib-uglify": "^0.4.0", + "grunt-karma": "~0.6.2" }, "engines": { "node": "~0.8 || ~0.10" }, - "scripts": { - "test": "./node_modules/.bin/karma start --single-run" - }, "assets": "src/main/webapp/" } diff --git a/sonar-server/pom.xml b/sonar-server/pom.xml index 381eeea2856..692b3198e11 100644 --- a/sonar-server/pom.xml +++ b/sonar-server/pom.xml @@ -279,6 +279,16 @@ install + + javascript tests + test + + grunt + + + karma + + generate-resources grunt build -- cgit v1.2.3