-
Notifications
You must be signed in to change notification settings - Fork 7
/
karma.conf.js
209 lines (163 loc) · 6.53 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// Karma configuration
// Generated on Mon Oct 29 2018 14:12:47 GMT-0400 (Eastern Daylight Time)
const path = require( 'path' );
const url = require( 'url' );
const proxy = require( 'express-http-proxy' );
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
const materialIconFiles = [
{ pattern: 'node_modules/material-icons/iconfont/material-icons.css', included: true },
{ pattern: 'node_modules/material-icons/iconfont/material-icons.woff', included: false },
{ pattern: 'node_modules/material-icons/iconfont/material-icons.woff2', included: false },
];
const webpackConfig = {
mode: 'development',
entry: './test/hoot/index.js',
module: {
rules: [
// instrument only testing sources with Istanbulvar fs = require('fs')
{
test: /\.(jpe?g|gif|png|svg|wav|mp3|woff(2)?|ttf|eot)$/,
type: 'asset/resource',
generator: {
filename: './img/[name][ext]',
},
},
{
test: /\.js$/,
use: {
loader: 'coverage-istanbul-loader',
options: { esModules: true }
},
include: path.resolve( __dirname, 'modules/Hoot/' ),
enforce: 'post'
},
{
test: /\.(scss|css)$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: './'
}
},
'css-loader',
'sass-loader'
]
}
]
},
resolve: {
alias: {
'./img': path.resolve( __dirname, 'img' ),
'lib': path.resolve( __dirname, 'modules/lib' ),
'data': path.resolve( __dirname, 'data' )
}
},
plugins: [
new MiniCssExtractPlugin( {
filename: '[name].css'
} ),
],
};
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: [ 'mocha', 'express-http-server' ],
client: {
mocha: {
// browserDisconnectTimeout : 210000,
// browserNoActivityTimeout : 210000,
timeout: 40000
}
},
// list of files / patterns to load in the browser
files: [
...materialIconFiles,
{ pattern: 'img/**/*.svg', included: false },
{ pattern: 'img/**/*.png', included: false },
{ pattern: 'img/**/*.gif', included: false },
{ pattern: 'test/data/UndividedHighway.osm', included: false },
{ pattern: 'test/data/highwayTest2.osm', included: false },
{ pattern: 'test/data/LAP030.dbf', included: false },
{ pattern: 'test/data/LAP030.shp', included: false },
{ pattern: 'test/data/LAP030.shx', included: false },
{ pattern: 'test/data/RomanColosseum_WV2naturalcolor_clip.tif', included: false},
// 'node_modules/chai/chai.js',
// 'node_modules/sinon/pkg/sinon.js',
// 'node_modules/sinon-chai/lib/sinon-chai.js',
// 'node_modules/happen/happen.js',
'css/**/*.css',
'css/**/*.scss',
// { pattern: 'dist/iD.min.js', included: true },
// { pattern: 'dist/iD.css', included: true },
// { pattern: 'dist/**/*', included: false },
// 'test/spec/spec_helpers.js',
// 'test/spec/*/!(localized|wikipedia).js',
'dist/globals.js',
'test/hoot/index.js'
],
// list of files / patterns to exclude
exclude: [],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'test/hoot/index.js': [ 'webpack' ],
'test/hoot/helpers.js': [ 'webpack' ],
'css/**/*.scss': [ 'scss' ]
},
proxies: {
'/img/': '/base/img/',
'/base/css/img/': '/base/img/',
'/base/css/hoot/img/': '/base/img/',
'/base/css/hoot/modules/img/': '/base/img/',
'/hoot-services': 'http://localhost:8787/hoot-services',
'/static' : 'http://localhost:8787/static'
},
expressHttpServer: {
port: '8787',
appVisitor: function( app ) {
app.use( '/hoot-services', proxy( 'http://localhost:8080', {
limit: '1000mb',
proxyReqOptDecorator: function( proxyReqOpts ) {
proxyReqOpts.headers.cookie = 'SESSION=ff47f751-c831-41ee-800f-5ef8b9371ee3; lock=1';
return proxyReqOpts;
},
proxyReqPathResolver: function( req ) {
return '/hoot-services' + url.parse(req.url).path;
}
} ) );
}
},
webpack: webpackConfig,
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: [ 'spec', 'coverage-istanbul' ],
coverageIstanbulReporter: {
reports: [ 'html', 'lcov', 'text-summary' ],
dir: path.join( __dirname, 'coverage' ),
fixWebpackSourcePaths: true
},
// 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: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [ 'ChromeHeadless' ],
// 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: 1
} );
};