-
Notifications
You must be signed in to change notification settings - Fork 21
/
karma-webpack.conf.js
73 lines (68 loc) · 2.21 KB
/
karma-webpack.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
// Karma-vite breaks Karma in Node <14, and browser tests don't depend on Node versions, so
// we just skip the tests in those environments.
const nodeMajorVersion = parseInt(process.versions.node.split('.'));
if (nodeMajorVersion <= 14) {
console.log('Skipping browser tests in old node version');
process.exit(0);
}
const tmp = require('tmp');
tmp.setGracefulCleanup();
const outputDir = tmp.dirSync({ unsafeCleanup: true }).name;
module.exports = function(config) {
config.set({
frameworks: ['mocha', 'chai', 'webpack'],
files: [
'test/**/*.spec.ts',
// Required due to https://github.com/ryanclark/karma-webpack/issues/498. Results in an
// annoying warning before the webpack build, but then it works fine.
{ pattern: `${outputDir}/*.wasm`, included: false, served: true }
],
mime: {
'text/x-typescript': ['ts']
},
webpack: {
mode: 'development',
devtool: 'source-map',
module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader',
options: {
configFile: 'test/tsconfig.json',
compilerOptions: {
outDir: tmp.dirSync({ unsafeCleanup: true }).name
}
},
exclude: /node_modules/
}
]
},
resolve: {
extensions: ['.ts', '.js'],
fallback: {
crypto: false
}
},
experiments: {
asyncWebAssembly: true
},
output: {
path: outputDir
}
},
webpackMiddleware: {
stats: 'error-only'
},
preprocessors: {
'test/**/*.ts': ['webpack', 'sourcemap']
},
reporters: ['spec'],
port: 9876,
logLevel: config.LOG_INFO,
browsers: ['ChromeHeadless'],
autoWatch: false,
singleRun: true,
concurrency: Infinity
});
};