Explorar o código

Got unit testing working, and made test debugging available in Chrome browsers.

jalbr74 %!s(int64=7) %!d(string=hai) anos
pai
achega
3cf782acef
Modificáronse 3 ficheiros con 973 adicións e 34 borrados
  1. 36 14
      client/karma.conf.js
  2. 934 20
      client/package-lock.json
  3. 3 0
      client/package.json

+ 36 - 14
client/karma.conf.js

@@ -20,12 +20,13 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-
+var webpack = require('webpack');
 var webpackConfig = require('./webpack.test.js');
+var path = require("path");
+var os = require('os');
 
 module.exports = function (config) {
     config.set({
-
         // base path that will be used to resolve all patterns (eg. files, exclude)
         basePath: '',
 
@@ -36,11 +37,11 @@ module.exports = function (config) {
         // list of files / patterns to load in the browser
         // Don't forget to add this to webpack.dev.js
         files: [
-            'node_modules/angular/angular.js',
-            'node_modules/angular-mocks/angular-mocks.js',
-            'node_modules/angular-translate/dist/angular-translate.js',
-            'vendor/angular-ui-router.js',
-            'src/main.ts',
+            // 'node_modules/angular/angular.js',
+            // 'node_modules/angular-mocks/angular-mocks.js',
+            // 'node_modules/angular-translate/dist/angular-translate.js',
+            // 'vendor/angular-ui-router.js',
+            // 'src/main.ts',
             'src/**/*.test.ts'
         ],
 
@@ -50,12 +51,24 @@ module.exports = function (config) {
         // preprocess matching files before serving them to the browser
         // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
         preprocessors: {
-            'src/main.ts': ['webpack'],
-            'src/**/*.test.ts': ['webpack']
+            "**/*.ts": ["webpack"]
         },
 
-        // webpack configuration
-        webpack: webpackConfig,
+        // fix typescript serving video/mp2t mime type
+        mime: {
+            'text/x-typescript': ['ts', 'tsx']
+        },
+
+        webpack: {
+            resolve: webpackConfig.resolve,
+            module: webpackConfig.module,
+            plugins: [
+                new webpack.SourceMapDevToolPlugin({
+                    filename: null, // if no value is provided the sourcemap is inlined
+                    test: /\.(ts|js)($|\?)/i // process .js and .ts files only
+                })
+            ]
+        },
 
         webpackMiddleware: {
             // display no info to console (only warnings and errors)
@@ -68,7 +81,7 @@ module.exports = function (config) {
         // test results reporter to use
         // possible values: 'dots', 'progress'
         // available reporters: https://npmjs.org/browse/keyword/karma-reporter
-        reporters: ['progress'],
+        reporters: ['kjhtml', 'spec'],
 
         // web server port
         port: 9876,
@@ -85,7 +98,16 @@ module.exports = function (config) {
 
         // start these browsers
         // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
-        browsers: [ 'PhantomJS' ],
+        browsers: ['Chrome_with_debug_plugins'],
+
+        // Provides the ability to install plugins in Chrome (such as JetBrains debugger), and have them stick around
+        // between launches:
+        customLaunchers: {
+            Chrome_with_debug_plugins: {
+                base: 'Chrome',
+                chromeDataDir: path.resolve(os.homedir(), '.karma/customLaunchers/Chrome_with_debug_plugins')
+            }
+        },
 
         // Continuous Integration mode
         // if true, Karma captures browsers, runs the tests and exits
@@ -95,4 +117,4 @@ module.exports = function (config) {
         // how many browser should be started simultaneous
         concurrency: Infinity
     })
-};
+};

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 934 - 20
client/package-lock.json


+ 3 - 0
client/package.json

@@ -43,8 +43,11 @@
     "json-loader": "0.5.4",
     "karma": "0.13.19",
     "karma-jasmine": "1.0.2",
+    "karma-jasmine-html-reporter": "0.2.2",
+    "karma-chrome-launcher": "2.2.0",
     "karma-phantomjs-launcher": "0.2.3",
     "karma-sourcemap-loader": "0.3.6",
+    "karma-spec-reporter": "0.0.32",
     "karma-webpack": "1.7.0",
     "ngtemplate-loader": "1.3.1",
     "node-sass": "3.10.1",

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio