-
Notifications
You must be signed in to change notification settings - Fork 142
/
Copy pathkarma.base.conf.js
99 lines (94 loc) · 3.12 KB
/
karma.base.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
const webpackConfig = require('../../webpack.base')({
mode: 'development',
types: ['jasmine', 'chrome'],
// do not replace some build env variables in unit test in order to test different build behaviors
keepBuildEnvVariables: ['SDK_VERSION'],
})
const { getTestReportDirectory } = require('../envUtils')
const jasmineSeedReporterPlugin = require('./jasmineSeedReporterPlugin')
const karmaSkippedFailedReporterPlugin = require('./karmaSkippedFailedReporterPlugin')
const reporters = ['spec', 'jasmine-seed', 'karma-skipped-failed']
const testReportDirectory = getTestReportDirectory()
if (testReportDirectory) {
reporters.push('junit')
}
module.exports = {
basePath: '../..',
files: [
// Make sure 'forEach.spec' is the first file to be loaded, so its `beforeEach` hook is executed
// before all other `beforeEach` hooks, and its `afterEach` hook is executed after all other
// `afterEach` hooks.
'packages/core/test/forEach.spec.ts',
'packages/*/@(src|test)/**/*.spec.@(ts|tsx)',
'developer-extension/@(src|test)/**/*.spec.@(ts|tsx)',
'packages/rum/test/toto.css',
],
frameworks: ['jasmine', 'webpack'],
client: {
jasmine: {
random: true,
stopSpecOnExpectationFailure: true,
},
},
preprocessors: {
'**/*.+(ts|tsx)': ['webpack', 'sourcemap'],
},
reporters,
specReporter: {
suppressErrorSummary: true,
suppressPassed: true,
suppressSkipped: true,
showBrowser: true,
},
junitReporter: {
outputDir: testReportDirectory,
},
singleRun: true,
webpack: {
stats: 'minimal',
module: overrideTsLoaderRule(webpackConfig.module),
resolve: webpackConfig.resolve,
target: webpackConfig.target,
devtool: false,
mode: 'development',
plugins: webpackConfig.plugins,
optimization: {
// By default, karma-webpack creates a bundle with one entry point for each spec file, but
// with all dependencies shared. Our test suite does not support sharing dependencies, each
// spec bundle should include its own copy of dependencies.
runtimeChunk: false,
splitChunks: false,
},
ignoreWarnings: [
// we will see warnings about missing exports in some files
// this is because we set transpileOnly option in ts-loader
{ message: /export .* was not found in/ },
],
},
webpackMiddleware: {
stats: 'errors-only',
logLevel: 'warn',
},
plugins: ['karma-*', jasmineSeedReporterPlugin, karmaSkippedFailedReporterPlugin],
// Running tests on low performance environments (ex: BrowserStack) can block JS execution for a
// few seconds. We need to increase those two timeout values to make sure Karma (and underlying
// Socket.io) does not consider that the browser crashed.
pingTimeout: 60_000,
browserNoActivityTimeout: 60_000,
}
function overrideTsLoaderRule(module) {
// We set transpileOnly to true to avoid type checking in unit tests
module.rules = module.rules.map((rule) => {
if (rule.loader === 'ts-loader') {
return {
...rule,
options: {
...rule.options,
transpileOnly: true,
},
}
}
return rule
})
return module
}