Skip to content

Commit 5437712

Browse files
committed
Add Angular Karma configuration for webapp
1 parent 05db62e commit 5437712

File tree

4 files changed

+81
-62
lines changed

4 files changed

+81
-62
lines changed

webapp/angular.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@
9999
"styles": [
100100
"src/styles.css"
101101
],
102-
"scripts": []
102+
"scripts": [],
103+
"karmaConfig": "karma.conf.js"
103104
}
104105
},
105106
"lint": {

webapp/karma.conf.js

+52-61
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,58 @@
1-
// Karma configuration
2-
// Generated on Mon Mar 11 2024 12:05:51 GMT+0100 (heure normale d’Europe centrale)
1+
// Karma configuration file, see link for more information
2+
// https://karma-runner.github.io/1.0/config/configuration-file.html
33

44
module.exports = function (config) {
55
config.set({
6-
7-
// base path that will be used to resolve all patterns (eg. files, exclude)
86
basePath: '',
9-
10-
11-
// frameworks to use
12-
// available frameworks: https://www.npmjs.com/search?q=keywords:karma-adapter
13-
frameworks: ['jasmine'],
14-
15-
16-
// list of files / patterns to load in the browser
17-
files: [
18-
'src/*.ts'
7+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
8+
plugins: [
9+
require('karma-jasmine'),
10+
require('karma-chrome-launcher'),
11+
require('karma-jasmine-html-reporter'),
12+
require('karma-coverage'),
13+
require('karma-junit-reporter'),
14+
require('@angular-devkit/build-angular/plugins/karma')
1915
],
20-
21-
22-
// list of files / patterns to exclude
23-
exclude: [],
24-
25-
26-
// preprocess matching files before serving them to the browser
27-
// available preprocessors: https://www.npmjs.com/search?q=keywords:karma-preprocessor
28-
preprocessors: {},
29-
30-
31-
// test results reporter to use
32-
// possible values: 'dots', 'progress'
33-
// available reporters: https://www.npmjs.com/search?q=keywords:karma-reporter
34-
reporters: ['progress'],
35-
36-
37-
// web server port
38-
port: 9876,
39-
40-
41-
// enable / disable colors in the output (reporters and logs)
42-
colors: true,
43-
44-
45-
// level of logging
46-
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
47-
logLevel: config.LOG_INFO,
48-
49-
50-
// enable / disable watching file and executing tests whenever any file changes
51-
autoWatch: true,
52-
53-
54-
// start these browsers
55-
// available browser launchers: https://www.npmjs.com/search?q=keywords:karma-launcher
16+
client: {
17+
jasmine: {
18+
// you can add configuration options for Jasmine here
19+
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
20+
// for example, you can disable the random execution with `random: false`
21+
// or set a specific seed with `seed: 4321`
22+
},
23+
clearContext: false // leave Jasmine Spec Runner output visible in browser
24+
},
25+
jasmineHtmlReporter: {
26+
suppressAll: true // removes the duplicated traces
27+
},
28+
coverageReporter: {
29+
dir: require('path').join(__dirname, './coverage/tcr'),
30+
subdir: '.',
31+
check: {
32+
global: {
33+
statements: 45,
34+
branches: 15, // Something wrong with the branch coverage
35+
functions: 25,
36+
lines: 45,
37+
},
38+
},
39+
reporters: [
40+
{type: 'html'},
41+
{type: 'text-summary'}
42+
]
43+
},
44+
junitReporter: {
45+
outputDir: '_test_results', // results will be saved as $outputDir/$browserName.xml
46+
outputFile: 'output.xml', // if included, results will be saved as $outputDir/$browserName/$outputFile
47+
suite: '', // suite will become the package name attribute in xml testsuite element
48+
useBrowserName: false, // add browser name to report and classes names
49+
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
50+
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
51+
properties: {}, // key value pair of properties to add to the <properties> section of the report
52+
xmlVersion: null, // use '1' if reporting to be per SonarQube 6.2 XML format
53+
},
54+
reporters: ['progress', 'kjhtml', 'junit'],
5655
browsers: ['Chrome'],
57-
58-
59-
// Continuous Integration mode
60-
// if true, Karma captures browsers, runs the tests and exits
61-
singleRun: true,
62-
63-
// Concurrency level
64-
// how many browser instances should be started simultaneously
65-
concurrency: Infinity
66-
})
67-
}
56+
restartOnFileChange: true
57+
});
58+
};

webapp/package-lock.json

+26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webapp/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"karma-coverage": "~2.2.0",
6262
"karma-jasmine": "~5.1.0",
6363
"karma-jasmine-html-reporter": "~2.1.0",
64+
"karma-junit-reporter": "^2.0.1",
6465
"typescript": "~5.2.2"
6566
}
6667
}

0 commit comments

Comments
 (0)