Skip to content

Commit 893e7fa

Browse files
committed
feat(testing): adds Karma configuration file for testing setup
- Created a new `karma.conf.js` file to configure Karma for testing. - Integrated Jasmine framework and Angular DevKit for testing support. - Added plugins for Chrome launcher, coverage reporting, and HTML reporting. - Configured coverage reporter to output results in the `./coverage/ng-kit` directory. - Set up reporters for progress and Jasmine HTML output. - Enabled automatic restart on file changes during testing.
1 parent dda2999 commit 893e7fa

File tree

4 files changed

+877
-309
lines changed

4 files changed

+877
-309
lines changed

angular.json

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,44 @@
99
"sourceRoot": "projects/ng-kit/src",
1010
"prefix": "lib",
1111
"architect": {
12-
"build": {
13-
"builder": "@angular-devkit/build-angular:ng-packagr",
14-
"options": {
15-
"project": "projects/ng-kit/ng-package.json"
16-
},
17-
"configurations": {
18-
"production": {
19-
"tsConfig": "projects/ng-kit/tsconfig.lib.prod.json"
20-
},
21-
"development": {
22-
"tsConfig": "projects/ng-kit/tsconfig.lib.json"
23-
}
24-
},
25-
"defaultConfiguration": "production"
26-
},
27-
"lint": {
28-
"builder": "@angular-eslint/builder:lint",
29-
"options": {
30-
"lintFilePatterns": [
31-
"src/**/*.ts",
32-
"src/**/*.html"
33-
]
34-
}
35-
},
36-
"test": {
37-
"builder": "@angular-devkit/build-angular:jest",
38-
"options": {
39-
"tsConfig": "projects/ng-kit/tsconfig.spec.json",
40-
"polyfills": [
41-
"zone.js",
42-
"zone.js/testing"
43-
]
44-
}
45-
}
46-
}
12+
"build": {
13+
"builder": "@angular-devkit/build-angular:ng-packagr",
14+
"options": {
15+
"project": "projects/ng-kit/ng-package.json"
16+
},
17+
"configurations": {
18+
"production": {
19+
"tsConfig": "projects/ng-kit/tsconfig.lib.prod.json"
20+
},
21+
"development": {
22+
"tsConfig": "projects/ng-kit/tsconfig.lib.json"
23+
}
24+
},
25+
"defaultConfiguration": "production"
26+
},
27+
"lint": {
28+
"builder": "@angular-eslint/builder:lint",
29+
"options": {
30+
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
31+
}
32+
},
33+
"test": {
34+
"builder": "@angular-devkit/build-angular:karma",
35+
"options": {
36+
"polyfills": [],
37+
"tsConfig": "tsconfig.spec.json",
38+
"assets": [
39+
{
40+
"glob": "**/*",
41+
"input": "public"
42+
}
43+
],
44+
"styles": ["src/styles.css"],
45+
"scripts": [],
46+
"karmaConfig": "karma.conf.js"
47+
}
48+
}
49+
}
4750
},
4851
"ng-kit-demo": {
4952
"projectType": "application",

karma.conf.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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/ng-kit'),
28+
subdir: '.',
29+
reporters: [{ type: 'html' }, { type: 'text-summary' }],
30+
},
31+
reporters: ['progress', 'kjhtml'],
32+
browsers: ['Chrome'],
33+
restartOnFileChange: true,
34+
});
35+
};

package.json

Lines changed: 86 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,87 @@
11
{
2-
"name": "ng-kit",
3-
"version": "19.6.0",
4-
"scripts": {
5-
"ng": "ng",
6-
"start": "ng serve --watch --hmr --port=4300",
7-
"build": "ng build ng-kit --configuration=production",
8-
"build:ng-kit-demo": "ng build ng-kit-demo --configuration=production",
9-
"watch": "ng build --watch --configuration development",
10-
"test": "ng test",
11-
"test:store": "ng test --include='**/store/*.spec.ts'",
12-
"bundle:report": "ng build --configuration production --source-map=true && source-map-explorer dist/pres/**/*.js",
13-
"e2e": "CI=true URL=http://localhost:4300 npx playwright test",
14-
"lint": "ng lint ng-kit"
15-
},
16-
"release": {
17-
"branches": [
18-
"main"
19-
],
20-
"plugins": [
21-
"@semantic-release/commit-analyzer",
22-
"@semantic-release/release-notes-generator",
23-
[
24-
"@semantic-release/npm",
25-
{
26-
"pkgRoot": "dist/ng-kit"
27-
}
28-
],
29-
"@semantic-release/git",
30-
"@semantic-release/github"
31-
]
32-
},
33-
"private": false,
34-
"dependencies": {
35-
"@angular/animations": "^19.2.0",
36-
"@angular/cdk": "19.2.1",
37-
"@angular/common": "^19.2.0",
38-
"@angular/compiler": "^19.2.0",
39-
"@angular/core": "^19.2.0",
40-
"@angular/forms": "^19.2.0",
41-
"@angular/material": "19.2.1",
42-
"@angular/platform-browser": "^19.2.0",
43-
"@angular/platform-browser-dynamic": "^19.2.0",
44-
"@angular/router": "^19.2.0",
45-
"bootstrap": "^5.3.3",
46-
"rxjs": "~7.8.1",
47-
"tslib": "^2.8.1",
48-
"zone.js": "~0.15.0"
49-
},
50-
"devDependencies": {
51-
"@angular-devkit/build-angular": "^19.2.0",
52-
"@angular-devkit/core": "^19.2.0",
53-
"@angular-devkit/schematics": "^19.2.0",
54-
"@angular-eslint/builder": "19.2.0",
55-
"@angular-eslint/eslint-plugin": "19.2.0",
56-
"@angular-eslint/eslint-plugin-template": "19.2.0",
57-
"@angular-eslint/schematics": "19.2.0",
58-
"@angular-eslint/template-parser": "19.2.0",
59-
"@angular/cli": "^19.2.0",
60-
"@angular/compiler-cli": "^19.2.0",
61-
"@playwright/test": "^1.49.1",
62-
"@sonar/scan": "^4.3.0",
63-
"@schematics/angular": "^19.1.1",
64-
"@semantic-release/git": "^10.0.1",
65-
"@semantic-release/npm": "^12.0.1",
66-
"@types/jest": "^29.5.14",
67-
"@types/node": "^22.10.7",
68-
"@typescript-eslint/eslint-plugin": "^8.20.0",
69-
"@typescript-eslint/parser": "^8.20.0",
70-
"eslint": "^9.18.0",
71-
"eslint-config-prettier": "^10.0.1",
72-
"eslint-plugin-import": "^2.31.0",
73-
"eslint-plugin-jsdoc": "^50.6.1",
74-
"eslint-plugin-prefer-arrow": "^1.2.3",
75-
"jest": "^29.7.0",
76-
"jest-environment-jsdom": "^29.7.0",
77-
"ng-packagr": "^19.1.0",
78-
"prettier": "^3.4.2",
79-
"semantic-release": "^24.2.1",
80-
"@semantic-release/exec": "^6.0.3",
81-
"typescript": "~5.7.3"
82-
}
83-
}
2+
"name": "ng-kit",
3+
"version": "19.6.0",
4+
"scripts": {
5+
"ng": "ng",
6+
"start": "ng serve --watch --hmr --port=4300",
7+
"build": "ng build ng-kit --configuration=production",
8+
"build:ng-kit-demo": "ng build ng-kit-demo --configuration=production",
9+
"watch": "ng build --watch --configuration development",
10+
"test": "ng test",
11+
"test:store": "ng test --include='**/store/*.spec.ts'",
12+
"bundle:report": "ng build --configuration production --source-map=true && source-map-explorer dist/pres/**/*.js",
13+
"e2e": "CI=true URL=http://localhost:4300 npx playwright test",
14+
"lint": "ng lint ng-kit"
15+
},
16+
"release": {
17+
"branches": [
18+
"main"
19+
],
20+
"plugins": [
21+
"@semantic-release/commit-analyzer",
22+
"@semantic-release/release-notes-generator",
23+
[
24+
"@semantic-release/npm",
25+
{
26+
"pkgRoot": "dist/ng-kit"
27+
}
28+
],
29+
"@semantic-release/git",
30+
"@semantic-release/github"
31+
]
32+
},
33+
"private": false,
34+
"dependencies": {
35+
"@angular/animations": "^19.2.0",
36+
"@angular/cdk": "19.2.1",
37+
"@angular/common": "^19.2.0",
38+
"@angular/compiler": "^19.2.0",
39+
"@angular/core": "^19.2.0",
40+
"@angular/forms": "^19.2.0",
41+
"@angular/material": "19.2.1",
42+
"@angular/platform-browser": "^19.2.0",
43+
"@angular/platform-browser-dynamic": "^19.2.0",
44+
"@angular/router": "^19.2.0",
45+
"bootstrap": "^5.3.3",
46+
"rxjs": "~7.8.1",
47+
"tslib": "^2.8.1",
48+
"zone.js": "~0.15.0"
49+
},
50+
"devDependencies": {
51+
"@angular-devkit/build-angular": "^19.2.0",
52+
"@angular-devkit/core": "^19.2.0",
53+
"@angular-devkit/schematics": "^19.2.0",
54+
"@angular-eslint/builder": "19.2.0",
55+
"@angular-eslint/eslint-plugin": "19.2.0",
56+
"@angular-eslint/eslint-plugin-template": "19.2.0",
57+
"@angular-eslint/schematics": "19.2.0",
58+
"@angular-eslint/template-parser": "19.2.0",
59+
"@angular/cli": "^19.2.0",
60+
"@angular/compiler-cli": "^19.2.0",
61+
"@playwright/test": "^1.49.1",
62+
"@sonar/scan": "^4.3.0",
63+
"@schematics/angular": "^19.1.1",
64+
"@semantic-release/git": "^10.0.1",
65+
"@semantic-release/npm": "^12.0.1",
66+
"@types/node": "^22.10.7",
67+
"@types/jasmine": "^5.1.7",
68+
"@typescript-eslint/eslint-plugin": "^8.20.0",
69+
"@typescript-eslint/parser": "^8.20.0",
70+
"eslint": "^9.18.0",
71+
"eslint-config-prettier": "^10.0.1",
72+
"eslint-plugin-import": "^2.31.0",
73+
"eslint-plugin-jsdoc": "^50.6.1",
74+
"eslint-plugin-prefer-arrow": "^1.2.3",
75+
"jasmine-core": "^5.6.0",
76+
"karma": "^6.4.4",
77+
"karma-chrome-launcher": "^3.2.0",
78+
"karma-coverage": "^2.2.1",
79+
"karma-jasmine": "^5.1.0",
80+
"karma-jasmine-html-reporter": "^2.1.0",
81+
"ng-packagr": "^19.1.0",
82+
"prettier": "^3.4.2",
83+
"semantic-release": "^24.2.1",
84+
"@semantic-release/exec": "^6.0.3",
85+
"typescript": "~5.7.3"
86+
}
87+
}

0 commit comments

Comments
 (0)