-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
207 lines (185 loc) · 5.35 KB
/
config.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
/*!
* Copyright 2012 - 2024 Digital Bazaar, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
import {config} from '@bedrock/core';
import {createRequire} from 'node:module';
import {fileURLToPath} from 'node:url';
import {VueLoaderPlugin} from 'vue-loader';
import fs from 'node:fs';
import path from 'node:path';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const require = createRequire(import.meta.url);
const DEFAULT_FRAMEWORKS = ['mocha', 'chai', 'webpack'];
const DEFAULT_PREPROCESSORS = ['babel', 'webpack'];
// add karma and coverage targets as available test framework
config.test.frameworks.push('karma');
config.test.frameworks.push('karma-coverage');
config.test.frameworks.push('karma-coverage-ci');
config.karma = {};
config.karma.suites = {};
config.karma.options = {};
config.karma.defaults = {
DEFAULT_FRAMEWORKS,
DEFAULT_PREPROCESSORS
};
config.karma.config = {
// 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: DEFAULT_FRAMEWORKS,
// list of files / patterns to load in the browser
files: [
require.resolve('regenerator-runtime/runtime')
],
// list of files to exclude
exclude: [],
// preprocess matching files before serving them to the browser
// available preprocessors:
// https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {},
webpack: {
mode: 'development',
module: {
rules: [
{
test: /\.js$/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'entry',
corejs: '3.22',
bugfixes: true,
targets: ['defaults', 'not IE 11']
}
]
]
}
}
]
},
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
]
},
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader'
]
},
{
test: /\.vue$/,
use: {
loader: 'vue-loader',
options: {
hotReload: false,
cssSourceMap: false
}
}
}
]
},
resolve: {
fallback: {
// empty to allow for apps to more easily add items
}
},
plugins: [
new VueLoaderPlugin(),
// FIXME: improve error handling method
function() {
this.hooks.done.tap('@bedrock/karma', stats => {
if(stats.hasErrors()) {
console.error('ERROR: webpack', {
errors: stats.hasErrors(),
warnings: stats.hasWarnings()
});
console.log(stats.toString({modules: false, colors: true}));
process.exit(1);
}
});
}
]
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
//reporters: ['progress'],
reporters: ['mocha'],
// NOTE: See index.js for coverage support
protocol: 'https:',
httpsServerOptions: {
key: fs.readFileSync(path.join(
__dirname, '..', 'pki', 'server.key'), 'utf8'),
cert: fs.readFileSync(path.join(
__dirname, '..', 'pki', 'server.crt'), 'utf8')
},
// 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_WARN,
// 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: ['PhantomJS', 'Chrome', 'Firefox', 'Safari'],
browsers: ['Chrome_without_security'],
customLaunchers: {
Chrome_without_security: {
base: 'ChromeHeadless',
flags: [
'--disable-web-security',
'--ignore-ssl-errors',
'--ignore-certificate-errors'
]
}
},
// 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: Infinity,
// Mocha
client: {
mocha: {
// increase from default 2s
timeout: 10000,
reporter: 'html'
//delay: true
}
},
// Proxied paths
proxies: {}
};