-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
135 lines (119 loc) · 4.76 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
var path = require('path');
var bodyParser = require('body-parser');
module.exports = function (config) {
config.set({
basePath: '.',
frameworks: ['mocha', 'chai-jquery', 'sinon', 'chai', 'jquery-1.8.3', 'express-http-server'],
singleRun: true, //just run once by default
client: {
//mocha configuration
mocha: {
timeout: 5000 // adding 3s to default timeout of 2000ms
}
},
files: [
'tests.webpack.js', //just load this file
{pattern: 'test/index.html', watched: false, served:true} // load html file
],
preprocessors: {
'test/index.html': ['html2js'], // helps load html file for dom testing
'tests.webpack.js': [ 'webpack', 'sourcemap'] //preprocess with webpack and our sourcemap loader
},
/**
* Configure webpack
*/
webpack: { //kind of a copy of your webpack config
debug:true,
devtool: 'inline-source-map', //just do inline source maps instead of the default
output: {
library: 'GCGraphSONTextPlugin',
libraryTarget: 'umd'
},
module: {
preLoaders: [
// instrument only testing sources with Istanbul
{
test: /\.js$/,
include: path.resolve('src/'),
loader: 'isparta'
}
],
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel' }
]
},
node: {
fs: 'empty'
}
},
/**
* Configure the mock server
* This will return fake ajax results
*/
expressHttpServer: {
port: 9999,
// this function takes express app object and allows you to modify it
// to your liking. For more see http://expressjs.com/4x/api.html
appVisitor: function (app, log) {
log.info('sum');
app.use( bodyParser.json() ); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));
app.post('/fiveplusfive', function (req, res) {
res.header("Content-Type", "application/json");
res.header('Access-Control-Allow-Origin', '*');
//default result
var result = { err:{message: "Incorrect POST params"} };
if(typeof req.body.gremlin !== "undefined" && req.body.gremlin == "5+5") {
// 5+5
result = { results:[10] };
} else if(typeof req.body.gremlin !== "undefined" && req.body.gremlin == "5+variable"
&& typeof req.body.bindings !== "undefined"
&& typeof req.body.bindings.variable !== "undefined"
&& req.body.bindings.variable == "5"
) {
// 5+variable (variable : 5)
result = { results:[10] };
}else if(typeof req.body.gremlin !== "undefined" && req.body.gremlin == "5+doesnotexist") {
// 5+doesnotexist (doesnotexist : undefined)
result = { err:{message:"No such property: doesnotexist for class: Script (Error 597)"} };
}
res.status(200).send(JSON.stringify(result));
});
}
},
reporters: ['mocha', 'coverage', 'coveralls'],
coverageReporter: {
type: 'lcov', // lcov or lcovonly are required for generating lcov.info files
dir: 'coverage/'
},
port: 9876,
colors: true,
autoWatch: false,
singleRun: false,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
browsers: [
'Firefox'
],
plugins: [
'karma-phantomjs-launcher',
'karma-firefox-launcher',
'karma-chrome-launcher',
'karma-mocha',
'karma-chai',
'karma-webpack',
'karma-sourcemap-loader',
'karma-mocha-reporter',
'karma-coverage',
'karma-coveralls',
'karma-html2js-preprocessor',
'karma-sinon',
'karma-chai-jquery',
'karma-jquery',
'karma-express-http-server'
]
});
};