-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarma.conf.js
165 lines (129 loc) · 5.07 KB
/
karma.conf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// Karma configuration
const angular = require('rollup-plugin-angular');
const commonjs = require('rollup-plugin-commonjs');
const nodeResolve = require('rollup-plugin-node-resolve');
const typescript = require('rollup-plugin-typescript');
const uglify = require('rollup-plugin-uglify');
const uglifyEs = require('uglify-es');
// rollup-plugin-angular addons
const sass = require('node-sass');
const CleanCSS = require('clean-css');
const htmlMinifier = require('html-minifier');
const cssmin = new CleanCSS();
const htmlminOpts = {
caseSensitive: true,
collapseWhitespace: true,
removeComments: true,
};
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: ['jasmine'],
// list of files / patterns to load in the browser
files: [
// Make sure to disable Karma’s file watcher
// because the preprocessor will use its own.
{ pattern: 'test/*.ts', watched: false },
{ pattern: 'src/*.spec.ts', watched: false },
{ pattern: 'src/**/*.spec.ts', watched: false }
],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-firefox-launcher'),
require('karma-coverage'),
require('karma-rollup-preprocessor'),
],
// 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/*.ts': ['rollup'],
'src/*.spec.ts': ['rollup'],
'src/**/*.spec.ts': ['rollup']
},
rollupPreprocessor: {
// will help to prevent conflicts between different tests entries
name: 'ngx-form.material',
format: 'umd',
sourcemap: 'inline',
// rollup settings. See Rollup documentation
plugins: [
angular({
preprocessors: {
template: template => htmlMinifier.minify(template, htmlminOpts),
style: scss => {
const css = sass.renderSync({ data: scss }).css;
return cssmin.minify(css).styles;
},
}
}),
commonjs(),
nodeResolve({
// use "module" field for ES6 module if possible
module: true, // Default: true
// use "jsnext:main" if possible
// – see https://github.com/rollup/rollup/wiki/jsnext:main
jsnext: true, // Default: false
// use "main" field or index.js, even if it's not an ES6 module
// (needs to be converted from CommonJS to ES6
// – see https://github.com/rollup/rollup-plugin-commonjs
main: true, // Default: true
// some package.json files have a `browser` field which
// specifies alternative files to load for people bundling
// for the browser. If that's you, use this option, otherwise
// pkg.browser will be ignored
browser: true, // Default: false
// not all files you want to resolve are .js files
extensions: [ '.js', '.json' ], // Default: ['.js']
// whether to prefer built-in modules (e.g. `fs`, `path`) or
// local ones with the same names
preferBuiltins: true, // Default: true
// Lock the module search in this path (like a chroot). Module defined
// outside this path will be mark has external
jail: '/', // Default: '/'
// If true, inspect resolved files to check that they are
// ES2015 modules
modulesOnly: false, // Default: false
// Any additional options that should be passed through
// to node-resolve
customResolveOptions: {}
}),
typescript({
typescript: require('./node_modules/typescript')
}),
// uglify({}, uglifyEs.minify)
]
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'kjhtml'],
// 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: true,
mime: {
'text/x-typescript': ['ts','tsx']
},
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Firefox'],
// 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
})
}