Browse Source

Run tests using Karma

Simen Bekkhus 10 years ago
parent
commit
823cdaa689
4 changed files with 95 additions and 18 deletions
  1. 0 1
      .editorconfig
  2. 11 3
      Gruntfile.js
  3. 68 0
      karma.conf.js
  4. 16 14
      package.json

+ 0 - 1
.editorconfig

@@ -7,7 +7,6 @@ trim_trailing_whitespace = true
 
 
 [*.js]
 [*.js]
 indent_style = tab
 indent_style = tab
-indent_size = 4
 
 
 [*.json]
 [*.json]
 indent_style = space
 indent_style = space

+ 11 - 3
Gruntfile.js

@@ -99,8 +99,16 @@ module.exports = function(grunt) {
 		pkg: grunt.file.readJSON('package.json'),
 		pkg: grunt.file.readJSON('package.json'),
 		uglify: createUglifyConfig("js"),
 		uglify: createUglifyConfig("js"),
 		clean: ["dist"],
 		clean: ["dist"],
-		qunit: {
-			files: ['qunit/qunit.html']
+		karma: {
+			options: {
+				configFile: 'karma.conf.js'
+			},
+			unit: {
+				runnerPort: 9999,
+				singleRun: true,
+				// browsers: ['PhantomJS'], // The tests fail...
+				logLevel: 'ERROR'
+			}
 		},
 		},
 		bump: {
 		bump: {
 			options: {
 			options: {
@@ -155,7 +163,7 @@ module.exports = function(grunt) {
 	grunt.registerTask('publish:patch', ['clean', 'bump:patch', 'uglify', 'shell:gitcommitchanges', 'release', 'nugetpack', 'nugetpush']);
 	grunt.registerTask('publish:patch', ['clean', 'bump:patch', 'uglify', 'shell:gitcommitchanges', 'release', 'nugetpack', 'nugetpush']);
 	grunt.registerTask('publish:minor', ['clean', 'bump:minor', 'uglify', 'shell:gitcommitchanges', 'release', 'nugetpack', 'nugetpush']);
 	grunt.registerTask('publish:minor', ['clean', 'bump:minor', 'uglify', 'shell:gitcommitchanges', 'release', 'nugetpack', 'nugetpush']);
 	grunt.registerTask('publish:major', ['clean', 'bump:major', 'uglify', 'shell:gitcommitchanges', 'release', 'nugetpack', 'nugetpush']);
 	grunt.registerTask('publish:major', ['clean', 'bump:major', 'uglify', 'shell:gitcommitchanges', 'release', 'nugetpack', 'nugetpush']);
-	grunt.registerTask('validate', ['eslint', 'qunit']);
+	grunt.registerTask('validate', ['eslint', 'karma']);
 
 
 	// Default task(s).
 	// Default task(s).
 	grunt.registerTask('default', ['bump:prerelease', 'clean', 'uglify']);
 	grunt.registerTask('default', ['bump:prerelease', 'clean', 'uglify']);

+ 68 - 0
karma.conf.js

@@ -0,0 +1,68 @@
+// Karma configuration
+// Generated on Tue Mar 31 2015 23:46:42 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: ['qunit'],
+
+
+		// list of files / patterns to load in the browser
+		files: [
+			'node_modules/jquery/dist/jquery.js',
+			//'js/**/*.js',
+			'dist/jquery.inputmask.bundle.js',
+			'qunit/prototypeExtensions.js',
+			'qunit/simulator.js',
+			'qunit/tests_*.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
+	})
+}

+ 16 - 14
package.json

@@ -4,18 +4,14 @@
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "main": "./dist/inputmask/jquery.inputmask.js",
   "main": "./dist/inputmask/jquery.inputmask.js",
   "files": [
   "files": [
-    "dist/inputmask/jquery.inputmask.js",
-    "dist/inputmask/inputmask.js",
-    "dist/inputmask/inputmask.extensions.js",
     "dist/inputmask/inputmask.date.extensions.js",
     "dist/inputmask/inputmask.date.extensions.js",
+    "dist/inputmask/inputmask.extensions.js",
+    "dist/inputmask/inputmask.js",
     "dist/inputmask/inputmask.numeric.extensions.js",
     "dist/inputmask/inputmask.numeric.extensions.js",
     "dist/inputmask/inputmask.phone.extensions.js",
     "dist/inputmask/inputmask.phone.extensions.js",
     "dist/inputmask/inputmask.regex.extensions.js",
     "dist/inputmask/inputmask.regex.extensions.js",
-    "./extra/phone-codes/phone-be.js",
-    "./extra/phone-codes/phone-codes.js",
-    "./extra/phone-codes/phone-nl.js",
-    "./extra/phone-codes/phone-ru.js",
-    "./extra/phone-codes/phone-uk.js"
+    "dist/inputmask/jquery.inputmask.js",
+    "extra/phone-codes/"
   ],
   ],
   "scripts": {
   "scripts": {
     "test": "grunt validate"
     "test": "grunt validate"
@@ -25,12 +21,13 @@
     "url": "https://github.com/RobinHerbots/jquery.inputmask.git"
     "url": "https://github.com/RobinHerbots/jquery.inputmask.git"
   },
   },
   "keywords": [
   "keywords": [
-    "jquery",
-    "plugins",
-    "input",
     "form",
     "form",
+    "input",
     "inputmask",
     "inputmask",
-    "mask"
+    "jquery",
+    "jquery-plugin",
+    "mask",
+    "plugins"
   ],
   ],
   "author": {
   "author": {
     "name": "Robin Herbots",
     "name": "Robin Herbots",
@@ -48,12 +45,17 @@
     "grunt": "^0.4.5",
     "grunt": "^0.4.5",
     "grunt-bump": "^0.3.0",
     "grunt-bump": "^0.3.0",
     "grunt-contrib-clean": "^0.6.0",
     "grunt-contrib-clean": "^0.6.0",
-    "grunt-contrib-qunit": "^0.7.0",
     "grunt-contrib-uglify": "^0.9.1",
     "grunt-contrib-uglify": "^0.9.1",
     "grunt-eslint": "^16.0.0",
     "grunt-eslint": "^16.0.0",
+    "grunt-karma": "^0.12.0",
     "grunt-nuget": "^0.1.4",
     "grunt-nuget": "^0.1.4",
     "grunt-release": "^0.12.0",
     "grunt-release": "^0.12.0",
     "grunt-shell": "^1.1.2",
     "grunt-shell": "^1.1.2",
-    "load-grunt-tasks": "^3.2.0"
+    "karma": "^0.13.3",
+    "karma-chrome-launcher": "^0.2.0",
+    "karma-phantomjs-launcher": "^0.2.0",
+    "karma-qunit": "^0.1.5",
+    "load-grunt-tasks": "^3.2.0",
+    "qunitjs": "^1.18.0"
   }
   }
 }
 }