-
Notifications
You must be signed in to change notification settings - Fork 142
/
karma.conf.js
56 lines (47 loc) · 1.29 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
// karma.conf.js
module.exports = function(config) {
config.set({
frameworks: ['browserify', 'mocha'],
preprocessors: {
'**/*.js': 'browserify'
},
browserify: {
debug: true
},
files: ['lib/*.js', 'test/*.test.js', 'test/*.js'],
reporters: ['spec'],
browsers: ['ChromeHeadless'],
middleware: ['server'],
failOnFailingTestSuite: false,
plugins: [
'karma-*',
{
'middleware:server': [
'factory',
function() {
return function(request, response, next) {
if (request.url === '/base/data' && request.method === 'POST') {
var body = '';
request.on('data', function(data) {
body += data;
});
request.on('end', function() {
try {
var data = JSON.parse(body);
response.writeHead(data.length === 3 ? 200 : 400);
return response.end(String(data.length === 3));
} catch (err) {
response.writeHead(500);
return response.end();
}
});
} else {
next();
}
};
}
]
}
]
});
};