forked from ethereumjs/ethereumjs-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarma.conf.js
67 lines (58 loc) · 2.59 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
module.exports = function (config) {
config.set({
frameworks: ['karma-typescript', 'tap'],
files: ['lib/**/*.ts', 'test/blockchain/chain.spec.ts'],
preprocessors: {
'**/*.ts': ['karma-typescript'],
},
reporters: ['progress'],
karmaTypescriptConfig: {
bundlerOptions: {
entrypoints: /\.spec\.ts$/,
acornOptions: {
ecmaVersion: 11,
},
// sourceMap: true,
exclude: ['async_hooks'],
resolve: {
alias: {
// Hotfix for `multiformats` client browser build error in Node 16, #1346, 2021-07-12
'multiformats/bases/base58': '../../node_modules/multiformats/cjs/src/bases/base58.js',
'multiformats/hashes/identity':
'../../node_modules/multiformats/cjs/src/hashes/identity.js',
'multiformats/hashes/sha2':
'../../node_modules/multiformats/cjs/src/hashes/sha2-browser.js',
},
},
transforms: [
require('karma-typescript-es6-transform')({
presets: [['@babel/preset-env', { targets: { chrome: '74' } }]],
}),
function (context, callback) {
// you may ask why on earth do we need this...,
// so this is to make sure `cjs` extensions are treated as actual scripts and not text files
// https://github.com/monounity/karma-typescript/blob/master/packages/karma-typescript/src/bundler/bundle-item.ts#L18 does not have cjs extension listed, so our file is not treated as script, and eventually require-ing it leads to a typeerror, since we get a string instead
// luckily it's an OR with rhs being `this.transformedScript` expression, so all we need to do is to set it to true (which we do below)
if (context.module.includes('web-encoding')) {
// needed to set a flag transformedScript on BundledItem described above, https://github.com/monounity/karma-typescript/blob/master/packages/karma-typescript/src/bundler/transformer.ts#L94
return callback(0, { dirty: true, transformedScript: true })
}
return callback(0, false)
},
],
},
tsconfig: './tsconfig.karma.json',
},
browsers: ['FirefoxHeadless', 'ChromeHeadless'],
colors: true,
// 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: 1,
// Fail after timeout
browserDisconnectTimeout: 100000,
browserNoActivityTimeout: 100000,
})
}