Skip to content

Commit 8729047

Browse files
committed
Karma setup
1 parent 025623c commit 8729047

File tree

10 files changed

+535
-60
lines changed

10 files changed

+535
-60
lines changed

.eslintrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ module.exports = {
6969

7070
overrides: [
7171
{
72-
files: ["./.eslintrc.js", "./src/**/*.ts"],
72+
files: ["./.eslintrc.js", "./karma.conf.js", "./src/**/*.ts"],
7373

7474
env: {
7575
es6: true,
@@ -173,7 +173,7 @@ module.exports = {
173173
},
174174

175175
{
176-
files: ["./.eslintrc.js"],
176+
files: ["./.eslintrc.js", "./karma.conf.js"],
177177

178178
env: {
179179
es6: true,

.github/workflows/publishLibrary.yml

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
build:
12-
name: Build package
12+
name: Build and publish library
1313
runs-on: ubuntu-latest
1414
if: github.repository_owner == 'float-toolkit'
1515

@@ -34,42 +34,11 @@ jobs:
3434
- name: Build
3535
run: npm run build:ci
3636

37-
- name: Upload dist artifact
38-
uses: actions/upload-artifact@v3
39-
with:
40-
name: dist
41-
path: dist
42-
43-
publish:
44-
name: Publish on NPM and GitHub Packages
45-
needs: build
46-
runs-on: ubuntu-latest
47-
48-
steps:
49-
- name: Checkout repository
50-
uses: actions/checkout@v3
51-
52-
- name: Download dist artifact
53-
uses: actions/download-artifact@v3
54-
with:
55-
name: dist
56-
path: dist
57-
58-
- name: Change to dist directory
59-
run: cd dist
60-
6137
- name: Publish on NPM
62-
uses: JS-DevTools/[email protected]
63-
with:
64-
access: public
65-
registry: https://registry.npmjs.org/
66-
token: ${{ secrets.NPM_TOKEN }}
67-
check-version: false
38+
run:
39+
npx npm-publish --access public --registry https://registry.npmjs.org/ --token ${{ secrets.NPM_TOKEN }} dist/package.json
6840

6941
- name: Publish on GitHub Packages
70-
uses: JS-DevTools/[email protected]
71-
with:
72-
access: public
73-
registry: https://npm.pkg.github.com/
74-
token: ${{ secrets.GITHUB_TOKEN }}
75-
check-version: false
42+
run:
43+
npx npm-publish --access public --registry https://npm.pkg.github.com/ --token ${{ secrets.GITHUB_TOKEN }}
44+
dist/package.json

.github/workflows/testWithKarma.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Test with Karma
22

33
on:
4-
# push:
5-
# branches-ignore:
6-
# - stable
4+
push:
5+
branches-ignore:
6+
- stable
77

88
workflow_dispatch:
99

angular.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@
3838

3939
"options": {
4040
"tsConfig": "./tsconfig.base.spec.json",
41-
"polyfills": ["zone.js", "zone.js/testing"]
41+
"karmaConfig": "./karma.conf.js",
42+
"polyfills": ["zone.js", "zone.js/testing"],
43+
44+
"watch": false,
45+
"codeCoverage": true
4246
}
4347
},
4448

jsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"noEmit": false
1515
},
1616

17-
"include": ["./.eslintrc.js", "./scripts/**/*.mjs"],
17+
"include": ["./.eslintrc.js", "./karma.conf.js"],
1818
"exclude": [],
1919
"references": []
2020
}

karma.conf.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* @param {import("karma").Config} config
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+
14+
// @ts-expect-error Does not find module, but compiles
15+
require("@angular-devkit/build-angular/plugins/karma"),
16+
],
17+
18+
client: {
19+
jasmine: {},
20+
clearContext: false,
21+
},
22+
customLaunchers: {
23+
ChromeCI: {
24+
base: "ChromeHeadless",
25+
flags: ["--no-sandbox", "--disable-gpu"],
26+
},
27+
},
28+
browsers: ["Chrome"],
29+
jasmineHtmlReporter: {
30+
suppressAll: true,
31+
},
32+
port: 9876,
33+
colors: true,
34+
logLevel: config.LOG_INFO,
35+
autoWatch: true,
36+
singleRun: false,
37+
restartOnFileChange: true,
38+
39+
coverageReporter: {
40+
dir: "./coverage",
41+
subdir: ".",
42+
reporters: [{ type: "cobertura" }, { type: "lcov" }, { type: "json" }, { type: "text" }],
43+
},
44+
reporters: ["progress", "kjhtml"],
45+
});
46+
};

0 commit comments

Comments
 (0)