Przeglądaj źródła

Updated unit testing libraries.

jalbr74 6 lat temu
rodzic
commit
ebb4fc846c
3 zmienionych plików z 23 dodań i 24 usunięć
  1. 10 10
      client/package.json
  2. 6 5
      client/test/karma-test-suite.ts
  3. 7 9
      client/test/karma.conf.js

+ 10 - 10
client/package.json

@@ -10,8 +10,8 @@
     "scripts": {
     "scripts": {
         "build": "webpack --mode=production",
         "build": "webpack --mode=production",
         "clean": "rimraf dist/",
         "clean": "rimraf dist/",
-        "test": "karma start test/karma.conf.js --mode=development",
-        "test-single-run": "karma start test/karma.conf.js --mode=development --singleRun --no-auto-watch",
+        "test": "karma start test/karma.conf.js",
+        "test-single-run": "karma start test/karma.conf.js --singleRun --no-auto-watch",
         "start": "webpack-dev-server --mode=development --port 4000 --history-api-fallback --colors",
         "start": "webpack-dev-server --mode=development --port 4000 --history-api-fallback --colors",
         "sync": "webpack --env.disableMinimize=true --mode=production --output-path=../webapp/target/pwm-1.8.0-SNAPSHOT/public/resources/webjars/pwm-client --watch --progress --colors"
         "sync": "webpack --env.disableMinimize=true --mode=production --output-path=../webapp/target/pwm-1.8.0-SNAPSHOT/public/resources/webjars/pwm-client --watch --progress --colors"
     },
     },
@@ -32,7 +32,7 @@
         "@types/angular-mocks": "1.5.11",
         "@types/angular-mocks": "1.5.11",
         "@types/angular-translate": "2.15.2",
         "@types/angular-translate": "2.15.2",
         "@types/angular-ui-router": "1.1.40",
         "@types/angular-ui-router": "1.1.40",
-        "@types/jasmine": "2.8.6",
+        "@types/jasmine": "2.8.9",
         "@types/node": "9.4.7",
         "@types/node": "9.4.7",
         "angular-mocks": "1.6.9",
         "angular-mocks": "1.6.9",
         "autoprefixer": "8.1.0",
         "autoprefixer": "8.1.0",
@@ -43,19 +43,19 @@
         "html-webpack-plugin": "3.0.6",
         "html-webpack-plugin": "3.0.6",
         "ignore-loader": "0.1.2",
         "ignore-loader": "0.1.2",
         "imports-loader": "0.8.0",
         "imports-loader": "0.8.0",
-        "jasmine": "3.1.0",
-        "jasmine-core": "3.1.0",
+        "jasmine": "3.2.0",
+        "jasmine-core": "3.2.1",
         "jshint": "2.9.5",
         "jshint": "2.9.5",
         "jshint-loader": "0.8.4",
         "jshint-loader": "0.8.4",
         "json-loader": "0.5.7",
         "json-loader": "0.5.7",
-        "karma": "2.0.0",
+        "karma": "3.1.1",
         "karma-chrome-launcher": "2.2.0",
         "karma-chrome-launcher": "2.2.0",
-        "karma-jasmine": "1.1.1",
-        "karma-jasmine-html-reporter": "1.0.0",
+        "karma-jasmine": "1.1.2",
+        "karma-jasmine-html-reporter": "1.3.1",
         "karma-phantomjs-launcher": "1.0.4",
         "karma-phantomjs-launcher": "1.0.4",
         "karma-sourcemap-loader": "0.3.7",
         "karma-sourcemap-loader": "0.3.7",
         "karma-spec-reporter": "0.0.32",
         "karma-spec-reporter": "0.0.32",
-        "karma-webpack": "2.0.13",
+        "karma-webpack": "3.0.5",
         "moment": "2.21.0",
         "moment": "2.21.0",
         "ngtemplate-loader": "2.0.1",
         "ngtemplate-loader": "2.0.1",
         "node-sass": "4.7.2",
         "node-sass": "4.7.2",
@@ -68,7 +68,7 @@
         "string-replace-loader": "2.1.1",
         "string-replace-loader": "2.1.1",
         "style-loader": "0.20.3",
         "style-loader": "0.20.3",
         "ts-loader": "4.0.1",
         "ts-loader": "4.0.1",
-        "ts-mockito": "2.3.0",
+        "ts-mockito": "2.3.1",
         "tslint": "5.9.1",
         "tslint": "5.9.1",
         "tslint-loader": "3.6.0",
         "tslint-loader": "3.6.0",
         "typescript": "2.7.2",
         "typescript": "2.7.2",

+ 6 - 5
client/test/karma-test-suite.ts

@@ -26,11 +26,12 @@ import 'angular';
 import 'angular-mocks';
 import 'angular-mocks';
 
 
 // This creates a single bundle with all test cases (*.test.ts), which improves performance
 // This creates a single bundle with all test cases (*.test.ts), which improves performance
-// (i.e. we don't create a webpack bundle for each test):
-var appContext = (require as any).context('../src', true, /\.test\.ts/);
+// (i.e. we don't create a webpack bundle for each test)
 
 
-// If you want to run a specific test, comment out the general line above, and uncomment the specific one below:
-// var appContext = (require as any).context('../src', true, /helpdesk-config\.service\.test\.ts/);
-// var appContext = (require as any).context('../src', true, /helpdesk\.service\.test\.ts/);
+// To run all tests, use this:
+// var appContext = (require as any).context('../src', true, /\.test\.ts/);
+
+// To run a specific test, change the following regular expression and use this:
+var appContext = (require as any).context('../src', true, /orgchart.component.test.ts/);
 
 
 appContext.keys().forEach(appContext);
 appContext.keys().forEach(appContext);

+ 7 - 9
client/test/karma.conf.js

@@ -21,7 +21,7 @@
  */
  */
 
 
 var webpack = require('webpack');
 var webpack = require('webpack');
-var webpackConfig = require('../webpack.test.js');
+var webpackConfig = require('../webpack.config.js')({}, {});
 var path = require("path");
 var path = require("path");
 var os = require('os');
 var os = require('os');
 
 
@@ -36,7 +36,7 @@ module.exports = function (config) {
 
 
         // list of files / patterns to load in the browser
         // list of files / patterns to load in the browser
         files: [
         files: [
-            'karma-test-suite.ts'
+            'test/karma-test-suite.ts'
         ],
         ],
 
 
         exclude: [],
         exclude: [],
@@ -53,15 +53,13 @@ module.exports = function (config) {
         },
         },
 
 
         webpack: {
         webpack: {
+            mode: 'development',
+            devtool: 'inline-source-map',
             resolve: webpackConfig.resolve,
             resolve: webpackConfig.resolve,
             module: webpackConfig.module,
             module: webpackConfig.module,
-            plugins: [
-                // Without this, we're not able to debug our tests in the browser:
-                new webpack.SourceMapDevToolPlugin({
-                    filename: null, // if no value is provided the sourcemap is inlined
-                    test: /\.(ts|js)($|\?)/i // process .js and .ts files only
-                })
-            ]
+            optimization: {
+                minimize: false
+            }
         },
         },
 
 
         webpackMiddleware: {
         webpackMiddleware: {