1
- module . exports = function ( config ) {
2
- config . set ( {
3
- browserNoActivityTimeout : 40000 ,
1
+ module . exports = function ( config ) {
2
+ const options = {
4
3
5
4
// base path that will be used to resolve all patterns (eg. files, exclude)
6
5
basePath : '' ,
@@ -12,6 +11,8 @@ module.exports = function(config) {
12
11
13
12
14
13
// list of files / patterns to load in the browser
14
+ // files: ['app/tests/**/*.ts'],
15
+
15
16
files : [
16
17
'app/tests/test-main.js' ,
17
18
'app/**/*.js' ,
@@ -32,7 +33,7 @@ module.exports = function(config) {
32
33
// test results reporter to use
33
34
// possible values: 'dots', 'progress'
34
35
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
35
- reporters : [ 'mocha ' ] ,
36
+ reporters : [ 'progress ' ] ,
36
37
37
38
38
39
// web server port
@@ -49,7 +50,7 @@ module.exports = function(config) {
49
50
50
51
51
52
// enable / disable watching file and executing tests whenever any file changes
52
- autoWatch : false ,
53
+ autoWatch : true ,
53
54
54
55
55
56
// start these browsers
@@ -74,6 +75,40 @@ module.exports = function(config) {
74
75
75
76
// Continuous Integration mode
76
77
// if true, Karma captures browsers, runs the tests and exits
77
- singleRun : true
78
- } )
78
+ singleRun : false
79
+ } ;
80
+
81
+ setWebpackPreprocessor ( config , options ) ;
82
+ setWebpack ( config , options ) ;
83
+
84
+ config . set ( options ) ;
85
+ }
86
+
87
+ function setWebpackPreprocessor ( config , options ) {
88
+ if ( config && config . bundle ) {
89
+ if ( ! options . preprocessors ) {
90
+ options . preprocessors = { } ;
91
+ }
92
+
93
+ options . files . forEach ( file => {
94
+ if ( ! options . preprocessors [ file ] ) {
95
+ options . preprocessors [ file ] = [ ] ;
96
+ }
97
+ options . preprocessors [ file ] . push ( 'webpack' ) ;
98
+ } ) ;
99
+ }
100
+ }
101
+
102
+ function setWebpack ( config , options ) {
103
+ if ( config && config . bundle ) {
104
+ const env = { } ;
105
+ env [ config . platform ] = true ;
106
+ env . sourceMap = config . debugBrk ;
107
+ options . webpack = require ( './webpack.config' ) ( env ) ;
108
+ delete options . webpack . entry ;
109
+ delete options . webpack . output . libraryTarget ;
110
+
111
+ const invalidPluginsForUnitTesting = [ "GenerateBundleStarterPlugin" , "GenerateNativeScriptEntryPointsPlugin" ] ;
112
+ options . webpack . plugins = options . webpack . plugins . filter ( p => ! invalidPluginsForUnitTesting . includes ( p . constructor . name ) ) ;
113
+ }
79
114
}
0 commit comments