-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkarma.conf.js
93 lines (85 loc) · 2.54 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
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
const puppeteer = require('puppeteer');
const os = require('node:os');
process.env.CHROME_BIN = puppeteer.executablePath();
const DEFAULT_PROCESSES_TO_SHARD = 2;
const JASMINE_DEFAULT_TIMEOUT = 15000;
let executors = os ? Math.ceil(os.cpus().length / 2) : DEFAULT_PROCESSES_TO_SHARD;
if (os) {
console.log('Total number of CPU\'s available:', os.cpus().length);
if (os.cpus().length <= 2) {
executors = os.cpus().length;
}
}
module.exports = (config) => {
config.set({
basePath: '',
frameworks: ['parallel', 'jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('karma-parallel'),
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-spec-reporter'),
],
webpackMiddleware: { stats: 'errors-only' },
webpackServer: { noInfo: true },
client: {
clearContext: config.singleRun, // leave Jasmine Spec Runner output visible in browser
jasmine: {
random: false,
timeoutInterval: (executors <= 2) ? (JASMINE_DEFAULT_TIMEOUT * 2) : JASMINE_DEFAULT_TIMEOUT,
},
},
jasmineHtmlReporter: {
suppressAll: false, // removes the duplicated traces
},
coverageReporter: {
dir: require('node:path')
.join(__dirname, './coverage/ngv'),
subdir: '.',
instrumenterOptions: {
istanbul: { noCompact: true },
},
reporters: [
{ type: 'html' },
{ type: 'lcovonly' },
{ type: 'text-summary' },
],
},
reporters: ['kjhtml', 'spec'],
port: 9876,
colors: true,
hostname: '0.0.0.0',
logLevel: config.LOG_INFO,
autoWatch: true,
specReporter: {
suppressSkipped: true,
showSpecTiming: true,
},
browsers: ['ChromeHeadlessNoSandbox'],
singleRun: false,
parallelOptions: {
executors,
},
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: [
'--headless',
'--disable-gpu',
// Without a remote debugging port, Google Chrome exits immediately.
'--remote-debugging-port=9222',
'--no-sandbox',
],
},
},
browserNoActivityTimeout: 120000,
browserSocketTimeout: 60000,
browserDisconnectTimeout: 200000,
captureTimeout: 240000,
});
};