Browse Source

Configured karma

Andrea Condoluci 9 năm trước cách đây
mục cha
commit
c8c45052c4
4 tập tin đã thay đổi với 122 bổ sung6 xóa
  1. 43 6
      Gruntfile.js
  2. 58 0
      karma.conf.js
  3. 15 0
      package.json
  4. 6 0
      typings.json

+ 43 - 6
Gruntfile.js

@@ -48,6 +48,43 @@ module.exports = function(grunt) {
         }
       }
     },*/
+    // Settings for tests
+    karma: {
+        // For continuous integration
+        ci: {
+            configFile: 'karma.conf.js',
+            options: {
+                browsers: ['PhantomJS', 'Chrome', 'Firefox'],
+                files: [
+                    '<%= browserify.debug.dest %>'
+                ]
+            }
+        },
+        debugWithFirefox: {
+            configFile: 'karma.conf.js',
+            options: {
+                singleRun: false,
+                browsers: ['Firefox'],
+                files: [
+                    '<%= browserify.debug.dest %>',
+                    {pattern: 'src/**/*.ts', included: false},
+                    {pattern: 'test/**/*.ts', included: false}
+                ]
+            }
+        },
+        debugWithChrome: {
+            configFile: 'karma.conf.js',
+            options: {
+                singleRun: false,
+                browsers: ['Chrome'],
+                files: [
+                    '<%= browserify.debug.dest %>',
+                    {pattern: 'src/**/*.ts', included: false},
+                    {pattern: 'test/**/*.ts', included: false}
+                ]
+            }
+        }
+    },
     // TSLint setup
     tslint: {
         options: {
@@ -87,15 +124,15 @@ module.exports = function(grunt) {
   grunt.loadNpmTasks('grunt-contrib-clean');
   grunt.loadNpmTasks('grunt-contrib-watch');
   //grunt.loadNpmTasks('grunt-jscs');
-  //grunt.loadNpmTasks('grunt-karma');
+  grunt.loadNpmTasks('grunt-karma');
   grunt.loadNpmTasks('grunt-tslint');
-  //grunt.loadNpmTasks('grunt-typings');
+  grunt.loadNpmTasks('grunt-typings');
 
-  grunt.registerTask('default', ['tslint', 'browserify'/*, 'karma:ci'*/]);
+  grunt.registerTask('default', ['tslint', 'browserify', 'karma:ci']);
   //grunt.registerTask('lint', ['tslint', 'jscs']);
-  grunt.registerTask('test', ['browserify:debug'/*, 'karma:ci'*/]);
-  //grunt.registerTask('test debug Firefox', ['browserify:debug', /*'karma:debugWithFirefox'*/]);
-  //grunt.registerTask('test debug Chrome', ['browserify:debug', /*'karma:debugWithChrome'*/]);
+  grunt.registerTask('test', ['browserify:debug', 'karma:ci']);
+  grunt.registerTask('test debug Firefox', ['browserify:debug', 'karma:debugWithFirefox']);
+  grunt.registerTask('test debug Chrome', ['browserify:debug', 'karma:debugWithChrome']);
   grunt.registerTask('rebuild', ['clean', 'default']);
   grunt.registerTask('publish', ['clean', 'browserify:dist']);
   grunt.registerTask('all', ['typings', 'default']);

+ 58 - 0
karma.conf.js

@@ -0,0 +1,58 @@
+// Karma configuration
+// Generated on Fri Feb 05 2016 12:36:08 GMT+0100 (CET)
+
+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: ['mocha', 'chai'],
+
+        // list of files / patterns to load in the browser
+        files: [
+          'build/**/*.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: ['mocha'],
+
+        // 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: false,
+
+        // start these browsers
+        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
+        browsers: [], // Will be overruled by karma grunt task options
+
+        // Continuous Integration mode
+        // if true, Karma captures browsers, runs the tests and exits
+        singleRun: true,
+
+        // Concurrency level
+        // how many browser should be started simultaneous
+        concurrency: Infinity
+    });
+};

+ 15 - 0
package.json

@@ -37,6 +37,21 @@
     "grunt-contrib-watch": "",
     "grunt-tslint": "",
     "grunt-contrib-uglify": "",
+    "grunt-karma": "",
+    "grunt-typings": "",
+
+    "chai": "",
+    "mocha": "",
+    "typescript": "",
+    "phantomjs-prebuilt": "",
+
+    "karma": "",
+    "karma-chai": "",
+    "karma-chrome-launcher": "",
+    "karma-firefox-launcher": "",
+    "karma-mocha": "",
+    "karma-mocha-reporter": "",
+    "karma-phantomjs-launcher": "",
 
     "vexflow": ""
   }

+ 6 - 0
typings.json

@@ -0,0 +1,6 @@
+{
+  "ambientDependencies": {
+    "chai": "registry:dt/chai#3.4.0+20160317120654",
+    "mocha": "registry:dt/mocha#2.2.5+20160317120654"
+  }
+}