Skip to content

Commit 1b97b0a

Browse files
authored
feat: migrate tests from Jest to Jasmine and update related configurations (#352)
* chore: update Node.js version to 20 and upgrade action versions in CI workflows * chore: upgrade actions/checkout to version 4 in CodeQL analysis workflow * feat: migrate tests from Jest to Jasmine and update related configurations * fix: update cookie regex to escape backslashes in cookie names * fix: use nullish coalescing for default sameSite value in cookie settings * fix: update test command to use ChromeHeadless browser for ngx-cookie-service * feat: add Karma configuration and update test scripts for ngx-cookie-service * fix: remove ChromeHeadless option from test command for ngx-cookie-service * fix: update test command to run in ChromeHeadless mode without watch
1 parent fc58af1 commit 1b97b0a

File tree

9 files changed

+6584
-8240
lines changed

9 files changed

+6584
-8240
lines changed

angular.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
}
2323
},
2424
"test": {
25-
"builder": "@angular-devkit/build-angular:jest",
25+
"builder": "@angular-devkit/build-angular:karma",
2626
"options": {
2727
"polyfills": ["zone.js", "zone.js/testing"],
28-
"tsConfig": "projects/ngx-cookie-service/tsconfig.spec.json"
28+
"tsConfig": "projects/ngx-cookie-service/tsconfig.spec.json",
29+
"karmaConfig": "karma.conf.js"
2930
}
3031
},
3132
"lint": {
@@ -58,9 +59,10 @@
5859
"defaultConfiguration": "production"
5960
},
6061
"test": {
61-
"builder": "@angular-devkit/build-angular:jest",
62+
"builder": "@angular-devkit/build-angular:karma",
6263
"options": {
63-
"tsConfig": "projects/ngx-cookie-service-ssr/tsconfig.spec.json"
64+
"tsConfig": "projects/ngx-cookie-service-ssr/tsconfig.spec.json",
65+
"karmaConfig": "karma.conf.js"
6466
}
6567
}
6668
}

karma.conf.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Karma configuration file, see link for more information
2+
// https://karma-runner.github.io/1.0/config/configuration-file.html
3+
4+
module.exports = function (config) {
5+
config.set({
6+
basePath: '',
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('@angular-devkit/build-angular/plugins/karma')
14+
],
15+
client: {
16+
jasmine: {
17+
// you can add configuration options for Jasmine here
18+
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19+
// for example, you can disable the random execution with `random: false`
20+
// or set a specific seed with `seed: 4321`
21+
},
22+
},
23+
jasmineHtmlReporter: {
24+
suppressAll: true // removes the duplicated traces
25+
},
26+
coverageReporter: {
27+
dir: require('path').join(__dirname, './coverage/pres'),
28+
subdir: '.',
29+
reporters: [
30+
{ type: 'html' },
31+
{ type: 'text-summary' }
32+
]
33+
},
34+
reporters: ['progress', 'kjhtml'],
35+
browsers: ['Chrome'],
36+
restartOnFileChange: true
37+
});
38+
};

0 commit comments

Comments
 (0)