forked from CoderLine/alphaTab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
154 lines (149 loc) · 4.96 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
const resolve = require('./rollup.resolve');
const commonjs = require('@rollup/plugin-commonjs');
const multer = require('multer');
const storage = multer.diskStorage({
destination: 'test-results/',
filename: function (req, file, cb) {
try {
cb(null, file.originalname);
} catch (e) {
const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1e9);
cb(null, file.fieldname + '-' + uniqueSuffix);
}
}
});
const upload = multer({ storage: storage });
const cors = require('cors');
const fs = require('fs');
const path = require('path');
module.exports = function (config) {
config.set({
frameworks: ['jasmine', 'express-http-server'],
files: [
{ pattern: 'dist/lib.test/test/index.js', watched: false },
{
pattern: 'test-data/**/*',
type: 'html',
watched: false,
included: false,
served: true,
nocache: true
},
{
pattern: 'font/**/*',
type: 'html',
watched: false,
included: false,
served: true,
nocache: true
}
],
preprocessors: {
'dist/lib.test/test/index.js': ['rollup']
},
client: {
clearContext: false,
jasmine: {
random: false,
stopSpecOnExpectationFailure: false.valueOf,
timeoutInterval: 30000
}
},
expressHttpServer: {
port: 8090,
appVisitor: function (app, log) {
app.use(cors());
app.get(
'/list-files',
function (req, res) {
log.info(`loading files from ${req.query.dir}`);
const directoryPath = path.join(__dirname, req.query.dir);
fs.readdir(directoryPath, (err, files) => {
//handling error
if (err) {
res.status(400);
res.send(JSON.stringify(`Error: ${err.message}`));
} else {
res.send(JSON.stringify(files.filter(f =>
fs.statSync(path.join(directoryPath, f)).isFile()
)));
}
});
}
);
app.post(
'/save-file',
upload.fields([
{
name: 'file',
maxCount: 1
}
]),
function (req, res) {
log.info(`save file ${req.file}`);
res.send(JSON.stringify('OK'));
}
);
app.post(
'/save-visual-error',
upload.fields([
{
name: 'expected',
maxCount: 1
},
{
name: 'actual',
maxCount: 1
},
{
name: 'diff',
maxCount: 1
}
]),
function (req, res) {
log.info(`save visual error ${req.file}`);
res.send(JSON.stringify('OK'));
}
);
app.post(
'/list-files',
upload.fields([
{
name: 'expected',
maxCount: 1
},
{
name: 'actual',
maxCount: 1
},
{
name: 'diff',
maxCount: 1
}
]),
function (req, res) {
log.info(`save visual error ${req.file}`);
res.send(JSON.stringify('OK'));
}
);
}
},
rollupPreprocessor: {
plugins: [
resolve({
mappings: {
'@src': 'dist/lib.test/src',
'@test': 'dist/lib.test/test'
}
}),
commonjs()
],
output: {
format: 'iife',
name: 'alphaTab',
file: 'dist/lib.test/test.bundle.js',
sourcemap: false
}
}
});
};