-
Notifications
You must be signed in to change notification settings - Fork 88
/
karma.conf.js
119 lines (113 loc) · 4.58 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
const tmp = require('tmp');
tmp.setGracefulCleanup();
const webpack = require('webpack');
const outputDir = tmp.dirSync({ unsafeCleanup: true }).name;
// Run a websocket server in the background for testing
require('./test/fixtures/websocket-test-server');
module.exports = function(config) {
config.set({
frameworks: ['mocha', 'chai', 'webpack'],
files: [
'test/**/*.spec.ts',
// Required for wasm 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}/**/*`, included: false, served: true }
],
mime: { 'text/x-typescript': ['ts'] },
webpack: {
mode: 'development',
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.js'],
alias: {
// Here we put stubs for non-browser modules that are used by tests, not core code.
// Core code stubs are set in pkgJson.browser.
"http-proxy-agent": require.resolve('./test/empty-stub.js'),
"https-proxy-agent": require.resolve('./test/empty-stub.js'),
"request-promise-native": require.resolve('./test/empty-stub.js'),
"portfinder": require.resolve('./test/empty-stub.js'),
"dns2": require.resolve('./test/empty-stub.js'),
"ws": require.resolve('./test/empty-stub.js')
},
fallback: {
// With Webpack 5, we need explicit mocks for all node modules. Because the
// tests are the same for node & browser, with tests simply skipped in
// browsers, plus some actual deps on node modules, we end up with a bunch
// of deps that need to be manually included/skipped here:
fs: false,
net: false,
http: false,
https: false,
http2: false,
tls: false,
assert: require.resolve('assert/'),
buffer: require.resolve('buffer/'),
crypto: require.resolve('crypto-browserify'),
zlib: require.resolve('browserify-zlib'),
stream: require.resolve('stream-browserify'),
path: require.resolve('path-browserify'),
querystring: require.resolve('querystring-es3'),
util: require.resolve('util/'),
url: require.resolve('url/')
}
},
module: {
rules: [
{ test: /\.ts$/, loader: 'ts-loader', exclude: /node_modules/ }
]
},
experiments: {
asyncWebAssembly: true
},
node: {
__dirname: true
},
plugins: [
new webpack.SourceMapDevToolPlugin({
test: /\.(ts|js|css)($|\?)/i
}),
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer'],
})
],
output: {
path: outputDir
}
},
webpackMiddleware: {
stats: 'error-only'
},
preprocessors: {
'src/**/*.ts': ['webpack', 'sourcemap'],
'test/**/*.ts': ['webpack', 'sourcemap']
},
plugins: [
'karma-chrome-launcher',
'karma-chai',
'karma-mocha',
'karma-sourcemap-loader',
'karma-webpack',
'karma-spec-reporter'
],
reporters: ['spec'],
port: 9876,
logLevel: config.LOG_INFO,
browsers: ['ChromeHeadlessWithCert'],
customLaunchers: {
ChromeHeadlessWithCert: {
base: 'ChromeHeadless',
// This is the fingerprint for the test-ca.pem CA cert
flags: ['--ignore-certificate-errors-spki-list=dV1LxiEDeQEtLjeMCGZ4ON7Mu1TvULkgt/kg1DGk/vM=']
},
// Used for debugging (npm run test:browser:debug)
ChromeWithCert: {
base: 'Chrome',
// This is the fingerprint for the test-ca.pem CA cert
flags: ['--ignore-certificate-errors-spki-list=dV1LxiEDeQEtLjeMCGZ4ON7Mu1TvULkgt/kg1DGk/vM=']
}
},
autoWatch: false,
singleRun: true
});
};