-
Notifications
You must be signed in to change notification settings - Fork 2
/
karma.conf.js
184 lines (153 loc) · 4.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
require("dotenv").config();
const moment = require("moment");
const pjson = require("./package.json");
let files = [];
let proxies = {};
let mime = {};
let exportFileSuffix = "";
if(process.env.TEST_CASE === "p5.wasm"){
files = [
`https://cdnjs.cloudflare.com/ajax/libs/p5.js/${pjson.p5js_version}/p5.min.js`,
"https://cdn.jsdelivr.net/npm/p5.wasm@0.3.1/dist/p5.wasm.js",
"tests/p5.wasm/test_setup.js",
`tests/p5.wasm/${process.env.TEST_MODULE || "*"}.js`
];
// Uncomment if testing WASM locally
// proxies = {
// "/wasm/": "/base/wasm/"
// };
// mime = {
// "application/wasm": ["wasm"]
// };
exportFileSuffix = "p5.wasm-0.3.1";
}else if(process.env.TEST_CASE === "q5.js"){
files = [
"https://cdn.jsdelivr.net/gh/LingDong-/q5xjs/q5.min.js",
"tests/q5.js/test_setup.js",
`tests/q5.js/${process.env.TEST_MODULE || "*"}.js`,
{
pattern: "tests/painting.png",
included: false,
served: true
}
];
proxies = {
"/": "/base/tests/"
};
exportFileSuffix = "q5.js-0.2.0";
}else{
files = [
`https://cdnjs.cloudflare.com/ajax/libs/p5.js/${pjson.p5js_version}/p5.min.js`,
"tests/p5.js/test_setup.js",
`tests/p5.js/${process.env.TEST_MODULE || "*"}.js`,
{
pattern: "tests/painting.png",
included: false,
served: true
}
];
proxies = {
"/": "/base/tests/"
};
exportFileSuffix = pjson.p5js_version
}
module.exports = function(config) {
config.set({
// DO NOT set to 0 or Infinity!
browserDisconnectTimeout: 10000,
// 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: [
"benchmark"
],
// list of files / patterns to load in the browser
files,
proxies,
mime,
// list of files / patterns to exclude
exclude: [
],
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: [
"benchmark",
"benchmark-json"
],
benchmarkJsonReporter: {
pathToJson: `results/benchmark-${exportFileSuffix}.json`,
formatResults: function(results){
return results.map(function(r){
if(r.suite !== "noop"){
return {
browser: r.browser,
suite: r.suite,
name: r.name,
opsPerSecond: r.hz,
marginOfError: `${r.rme}%`
};
}
}).filter((r) => {
return r !== undefined;
}).sort(function(el1, el2){
if(el1.suite > el2.suite){
return 1;
}else if(el1.suite < el2.suite){
return -1;
}else{
if(el1.name > el2.name){
return 1;
}else if(el1.name < el2.name){
return -1;
}else{
return 0;
}
}
});
},
formatOutput: function(results){
// Not including summary in final result for now, not very useful
// const summary = results.reduce(function(acc, result){
// if(typeof acc[result.suite] === "undefined"){
// acc[result.suite] = result;
// }else if(acc[result.suite].opsPerSecond < result.opsPerSecond){
// acc[result.suite] = result;
// }
// return acc;
// }, {});
return {
meta: {
title: "p5.js Benchmarks",
version: pjson.p5js_version,
date: moment().toISOString()
},
results: results,
summary: {}
};
}
},
// 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_ERROR,
// 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: [
"FirefoxHeadless",
"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
});
};