-
Notifications
You must be signed in to change notification settings - Fork 2
/
karma.config.cjs
92 lines (89 loc) · 2.55 KB
/
karma.config.cjs
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
process.env.CHROME_BIN = require('puppeteer').executablePath();
const webpack = require('webpack');
const Dotenv = require('dotenv-webpack');
module.exports = function (config) {
config.set({
plugins: [
'karma-jasmine',
'karma-chrome-launcher',
'karma-webpack',
'karma-spec-reporter',
require('./tests/karma-polly.cjs'),
],
basePath: './',
frameworks: ['jasmine', 'webpack', 'polly'],
files: [
{ pattern: 'tests/karma-setup.js', watched: false },
{ pattern: 'tests/integration/*.ts', watched: false },
],
reporters: ['spec'],
preprocessors: {
'tests/integration/*.ts': ['webpack'],
'tests/karma-setup.js': ['webpack'],
},
pollyConfig: {
recordings: './tests/__recordings__/browser',
port: 3000,
},
browsers: ['Chrome_without_security'],
customLaunchers: {
Chrome_without_security: {
base: 'ChromeHeadless',
flags: ['--disable-web-security', '--disable-site-isolation-trials'],
},
},
webpack: {
watch: true,
resolve: {
fallback: {
path: require.resolve('path-browserify'),
util: require.resolve('util/'),
fs: false,
url: require.resolve('url/'),
process: require.resolve('process/browser'),
module: false,
crypto: false,
process: require.resolve('process/browser'),
stream: false,
assert: require.resolve('assert/'),
http: false,
https: false,
os: require.resolve('os-browserify'),
buffer: false,
},
extensions: ['.ts', '.js', '.cjs'],
},
plugins: [
new webpack.DefinePlugin({
__isBrowser__: 'true',
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new Dotenv(),
],
module: {
rules: [
{ test: /graceful-fs/, use: 'null-loader' },
{ test: /pollyjs\/persister-fs/, use: 'null-loader' },
{ test: /pollyjs\/adapter-node-http/, use: 'null-loader' },
{ test: /requireOrImportModule/, use: 'null-loader' },
{ test: /testing-library\/react/, use: 'null-loader' },
{
test: /\.ts$/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
configFile: 'tsconfig.json',
},
},
],
exclude: /node_modules/,
},
],
},
},
});
};