1+ const path = require ( 'path' ) ;
12module . exports = function ( config ) {
23 config . set ( {
34 //root path location to resolve paths defined in files and exclude
@@ -6,15 +7,7 @@ module.exports = function (config) {
67 exclude : [ ] ,
78 //files/patterns to load in the browser
89 files : [
9- { pattern : 'test-context.js' , watched : false }
10- /*parameters:
11- watched: if autoWatch is true all files that have set watched to true will be watched for changes
12- served: should the files be served by Karma's webserver?
13- included: should the files be included in the browser using <script> tag?
14- nocache: should the files be served from disk on each request by Karma's webserver? */
15- /*assets:
16- {pattern: '*.html', watched:true, served:true, included:false}
17- {pattern: 'images/*', watched:false, served:true, included:false} */
10+ { pattern : "spec/**/*.ts" }
1811 ] ,
1912
2013 //executes the tests whenever one of watched files changes
@@ -27,7 +20,7 @@ module.exports = function (config) {
2720 logLevel : config . LOG_WARN , //config.LOG_DISABLE, config.LOG_ERROR, config.LOG_INFO, config.LOG_DEBUG
2821
2922 //list of frameworks you want to use, only jasmine is installed with this boilerplate
30- frameworks : [ 'jasmine' ] ,
23+ frameworks : [ 'jasmine' , 'karma-typescript' ] ,
3124 //list of browsers to launch and capture
3225 browsers : [ 'ChromeHeadlessNoSandbox' /*,'PhantomJS','Firefox','Edge','ChromeCanary','Opera','IE','Safari'*/ ] ,
3326 //list of reporters to use
@@ -52,7 +45,7 @@ module.exports = function (config) {
5245 //capture all console output and pipe it to the terminal, true is default
5346 captureConsole : false ,
5447 //if true, Karma clears the context window upon the completion of running the tests, true is default
55- clearContext : false ,
48+ clearContext : true ,
5649 //run the tests on the same window as the client, without using iframe or a new window, false is default
5750 runInParent : false ,
5851 //true: runs the tests inside an iFrame; false: runs the tests in a new window, true is default
@@ -64,39 +57,26 @@ module.exports = function (config) {
6457 } ,
6558 plugins : [
6659 require ( 'karma-jasmine' ) ,
67- require ( ' karma-webpack' ) ,
60+ require ( " karma-typescript" ) ,
6861 require ( 'karma-spec-reporter' ) ,
6962 require ( 'karma-jasmine-html-reporter' ) ,
7063 require ( 'karma-chrome-launcher' )
7164 ] ,
72- /* karma-webpack config
73- pass your webpack configuration for karma
74- add `babel-loader` to the webpack configuration to make
75- the ES6+ code in the test files readable to the browser
76- eg. import, export keywords */
77- webpack : {
78- optimization : {
79- minimize : false
80- } ,
81- devtool : 'inline-source-map' ,
82- module : {
83- rules : [
84- {
85- test : / \. j s $ / i,
86- exclude : / ( n o d e _ m o d u l e s ) / ,
87- loader : 'babel-loader'
88- }
89- ]
90- }
91- } ,
9265 preprocessors : {
93- //add webpack as preprocessor to support require() in test-suits .js files
94- 'test-context.js' : [ 'webpack' ]
66+ "**/*.ts" : "karma-typescript" // *.tsx for React Jsx
9567 } ,
96- webpackMiddleware : {
97- //turn off webpack bash output when run the tests
98- noInfo : false ,
99- stats : 'errors-only'
68+ karmaTypescriptConfig : {
69+ tsconfig : "./tsconfig.spec.json" ,
70+ bundlerOptions : {
71+ transforms : [
72+ require ( 'karma-typescript-es6-transform' ) ( )
73+ ] ,
74+ resolve : {
75+ alias : {
76+ "@themost/xml" : path . resolve ( __dirname , './dist/index.js' ) ,
77+ }
78+ }
79+ }
10080 } ,
10181 customLaunchers : {
10282 ChromeNoSandbox : {
0 commit comments