forked from getodk/central-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkarma.conf.js
More file actions
96 lines (90 loc) · 3.2 KB
/
karma.conf.js
File metadata and controls
96 lines (90 loc) · 3.2 KB
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
/*
This config is based on:
- https://vue-test-utils.vuejs.org/installation/#using-other-test-runners
- https://github.com/eddyerburgh/vue-test-utils-karma-example
- https://github.com/eddyerburgh/avoriaz-karma-mocha-example
- https://github.com/Nikku/karma-browserify
*/
// eslint-disable-next-line import/no-unresolved
const VueI18nPlugin = require('@intlify/unplugin-vue-i18n/webpack');
// eslint-disable-next-line import/no-extraneous-dependencies
const { DefinePlugin } = require('webpack');
const { resolve } = require('node:path');
const { readFileSync } = require('fs');
// eslint-disable-next-line import/extensions
const webpackConfig = require('./node_modules/@vue/cli-service/webpack.config.js');
const webFormsPackage = JSON.parse(
readFileSync(resolve(__dirname, 'node_modules/@getodk/web-forms/package.json'), 'utf-8')
);
const { entry, ...webpackConfigForKarma } = webpackConfig;
webpackConfigForKarma.plugins.push(
VueI18nPlugin({
include: resolve(__dirname, './src/locales/**'),
compositionOnly: false,
defaultSFCLang: 'json5',
// `false` doesn't work for some reason. When `false` is specified, Vue I18n
// warns that it's been installed already.
fullInstall: true,
dropMessageCompiler: true
}),
new DefinePlugin({
__WEB_FORMS_VERSION__: JSON.stringify(webFormsPackage.version)
})
);
// eslint-disable-next-line arrow-body-style
webpackConfigForKarma.plugins = webpackConfigForKarma.plugins.filter(plugin => {
return plugin.constructor.name !== 'HtmlWebpackPlugin';
});
webpackConfigForKarma.devtool = 'inline-source-map';
// See additional warning information.
webpackConfigForKarma.stats = {
...webpackConfigForKarma.stats,
children: true,
errorDetails: true
};
webpackConfigForKarma.module.rules.push({
test: /\.xml$/,
use: 'raw-loader'
});
module.exports = (config) => {
config.set({
frameworks: ['webpack', 'mocha', 'source-map-support'],
files: [
'test/index.js',
{ pattern: 'public/fonts/icomoon.ttf', served: true, included: false },
{ pattern: 'public/blank.html', served: true, included: false },
{ pattern: 'test/files/*', served: true, included: false },
{ pattern: 'src/assets/images/**', served: true, included: false }
],
proxies: {
'/fonts/': '/base/public/fonts/',
'/blank.html': '/base/public/blank.html',
'/test/files/': '/base/test/files/',
// Images
'/img/banner@1x.2ab8c238.png': '/base/src/assets/images/whats-new/banner@1x.png', // Smaller resolution for circleCI test
'/img/map-location.b523ce2d.svg': '/base/src/assets/images/geojson-map/map-location.svg',
'/img/fullscreen.37a932a6.svg': '/base/src/assets/images/geojson-map/fullscreen.svg'
},
preprocessors: {
'test/index.js': ['webpack', 'sourcemap']
},
webpack: webpackConfigForKarma,
browsers: ['ChromeHeadless'],
browserDisconnectTimeout: 300_000,
browserDisconnectTolerance: 3,
reporters: ['spec'],
singleRun: true,
client: {
mocha: {
grep: process.env.TEST_PATTERN || '.',
timeout: 4000,
},
},
customLaunchers: {
ChromeDebugging: {
base: 'Chrome',
flags: ['--remote-debugging-port=8333']
}
}
});
};