Skip to content

Commit 89cea35

Browse files
authored
Merge pull request #21 from expressots/refactor/adjust-config-test-codecov
Refactor/adjust config test codecov
2 parents a43507b + aef20eb commit 89cea35

10 files changed

+123
-87
lines changed

.eslintrc.cjs

+32-26
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
/* eslint-env node */
22
module.exports = {
3-
extends: [
4-
"eslint:recommended",
5-
"plugin:@typescript-eslint/recommended",
6-
"eslint-config-prettier",
7-
"prettier"
8-
],
9-
parser: "@typescript-eslint/parser",
10-
parserOptions: {
11-
project: ["./tsconfig.cjs.json"]
12-
},
13-
plugins: ["@typescript-eslint"],
14-
root: true,
15-
env: {
16-
node: true,
17-
jest: true,
18-
},
19-
ignorePatterns: ["dist", "node_modules", ".eslintrc.cjs"],
20-
rules: {
21-
"@typescript-eslint/adjacent-overload-signatures": "error",
22-
"@typescript-eslint/array-type": ["error", { default: "generic" }],
23-
"@typescript-eslint/await-thenable": "error",
24-
"@typescript-eslint/ban-types": "error",
25-
"@typescript-eslint/class-literal-property-style": "error",
26-
"@typescript-eslint/explicit-function-return-type": "error",
27-
},
28-
}
3+
extends: [
4+
"eslint:recommended",
5+
"plugin:@typescript-eslint/recommended",
6+
"eslint-config-prettier",
7+
"prettier",
8+
],
9+
parser: "@typescript-eslint/parser",
10+
parserOptions: {
11+
project: ["./tsconfig.cjs.json", "./tsconfig.json"],
12+
},
13+
plugins: ["@typescript-eslint"],
14+
root: true,
15+
env: {
16+
node: true,
17+
jest: true,
18+
},
19+
ignorePatterns: [
20+
"dist",
21+
"node_modules",
22+
".eslintrc.cjs",
23+
"**/__tests__/*.spec.ts",
24+
"vitest.config.ts",
25+
],
26+
rules: {
27+
"@typescript-eslint/adjacent-overload-signatures": "error",
28+
"@typescript-eslint/array-type": ["error", { default: "generic" }],
29+
"@typescript-eslint/await-thenable": "error",
30+
"@typescript-eslint/ban-types": "error",
31+
"@typescript-eslint/class-literal-property-style": "error",
32+
"@typescript-eslint/explicit-function-return-type": "error",
33+
},
34+
};

.github/workflows/build.yaml

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
name: Build
1+
name: Build and Test
22

33
on:
44
push:
55
branches:
66
- main
77
pull_request:
8-
# The branches below must be a subset of the branches above
98
branches: ["main"]
109
pull_request_target:
1110
types: [opened, synchronize, reopened]
@@ -29,13 +28,24 @@ jobs:
2928
- name: Build
3029
run: npm run build
3130

32-
#- name: Unit Tests
33-
# working-directory: .
34-
# run: npm test
35-
# env:
36-
# CI: true
31+
- name: Unit Tests
32+
working-directory: ./src
33+
run: npm run test
34+
env:
35+
CI: true
3736

38-
#- name: Set up .npmrc
39-
# run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
40-
#- name: Install dependencies
41-
# run: npm ci
37+
- name: Run Code Coverage
38+
working-directory: ./src
39+
run: npm run coverage
40+
41+
- name: Upload coverage reports to Codecov
42+
uses: codecov/codecov-action@v4.0.1
43+
with:
44+
working-directory: .
45+
token: ${{ secrets.CODECOV_TOKEN }}
46+
47+
- name: Set up .npmrc
48+
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc
49+
50+
- name: Install dependencies
51+
run: npm ci

.github/workflows/codesee-arch-diagram.yml

-23
This file was deleted.

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
<!-- PROJECT SHIELDS -->
44

5+
[![Codecov][codecov-shield]][codecov-url]
6+
[![NPM][npm-shield]][npm-url]
7+
![Build][build-shield]
58
[![Contributors][contributors-shield]][contributors-url]
69
[![Forks][forks-shield]][forks-url]
710
[![Stargazers][stars-shield]][stars-url]
@@ -95,6 +98,11 @@ Distributed under the MIT License. See [`LICENSE.txt`](https://github.com/expres
9598
<!-- MARKDOWN LINKS & IMAGES -->
9699
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
97100

101+
[codecov-url]: https://codecov.io/gh/expressots/adapter-express
102+
[codecov-shield]: https://img.shields.io/codecov/c/gh/expressots/adapter-express/main?style=for-the-badge&logo=codecov&labelColor=FB9AD1
103+
[npm-url]: https://www.npmjs.com/package/@expressots/adapter-express
104+
[npm-shield]: https://img.shields.io/npm/v/@expressots/adapter-express?style=for-the-badge&logo=npm&color=9B3922
105+
[build-shield]: https://img.shields.io/github/actions/workflow/status/expressots/adapter-express/build.yml?branch=main&style=for-the-badge&logo=github
98106
[contributors-shield]: https://img.shields.io/github/contributors/expressots/adapter-express?style=for-the-badge
99107
[contributors-url]: https://github.com/expressots/adapter-express/graphs/contributors
100108
[forks-shield]: https://img.shields.io/github/forks/expressots/adapter-express?style=for-the-badge

jest.config.ts

-19
This file was deleted.

package.json

+11-5
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@
5757
"build:cjs": "tsc -p tsconfig.cjs.json",
5858
"release": "release-it",
5959
"prepublish": "npm run build && npm pack",
60-
"test": "jest",
60+
"publish": "npm publish --tag latest",
61+
"test": "vitest run --reporter default",
62+
"test:watch": "vitest run --watch",
63+
"coverage": "vitest run --coverage",
6164
"format": "prettier --write \"src/**/*.ts\" --cache",
6265
"lint": "eslint \"src/**/*.ts\"",
6366
"lint:fix": "eslint \"src/**/*.ts\" --fix"
@@ -66,26 +69,29 @@
6669
"dotenv": "16.4.5",
6770
"inversify": "6.0.2",
6871
"inversify-binding-decorators": "4.0.0",
69-
"jest": "29.5.0",
7072
"reflect-metadata": "0.2.2"
7173
},
7274
"devDependencies": {
73-
"@commitlint/cli": "^18.0.0",
75+
"@codecov/vite-plugin": "^0.0.1-beta.6",
76+
"@commitlint/cli": "18.0.0",
7477
"@commitlint/config-conventional": "17.7.0",
7578
"@expressots/core": "latest",
7679
"@release-it/conventional-changelog": "7.0.1",
7780
"@types/express": "4.17.21",
78-
"@types/jest": "29.5.0",
7981
"@types/node": "20.4.9",
8082
"@typescript-eslint/eslint-plugin": "6.6.0",
8183
"@typescript-eslint/parser": "6.6.0",
84+
"@vitest/coverage-v8": "^1.4.0",
8285
"eslint": "8.48.0",
8386
"eslint-config-prettier": "9.0.0",
8487
"husky": "8.0.3",
8588
"prettier": "3.0.3",
8689
"release-it": "16.1.5",
8790
"ts-jest": "29.0.5",
88-
"typescript": "5.2.2"
91+
"typescript": "5.2.2",
92+
"vite": "^5.2.8",
93+
"vite-tsconfig-paths": "^4.3.2",
94+
"vitest": "^1.4.0"
8995
},
9096
"release-it": {
9197
"git": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { describe, expect, it } from "vitest";
2+
3+
describe("application-express", () => {
4+
it("should have tests", () => {
5+
expect(true).toBe(true);
6+
});
7+
});

tsconfig.cjs.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "./tsconfig.base.json",
2+
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"module": "commonjs",
55
"target": "ES2021",

tsconfig.base.json tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"allowSyntheticDefaultImports": true,
1313
"experimentalDecorators": true,
1414
"emitDecoratorMetadata": true,
15-
"types": ["node", "reflect-metadata", "jest"]
15+
"types": ["node", "reflect-metadata", "vitest/globals"]
1616
},
1717
"include": ["./src/**/*.ts"],
18-
"exclude": ["node_modules"]
18+
"exclude": ["node_modules", "**/__tests__/*.spec.ts", "scripts/**/*"]
1919
}

vitest.config.ts

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { defineConfig } from "vitest/config";
2+
import { codecovVitePlugin } from "@codecov/vite-plugin";
3+
import tsconfigPaths from "vite-tsconfig-paths";
4+
5+
/**
6+
* @see {@link https://vitejs.dev/config/}
7+
* @see {@link https://vitest.dev/config/}
8+
*/
9+
export default defineConfig({
10+
plugins: [
11+
tsconfigPaths(),
12+
codecovVitePlugin({
13+
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
14+
bundleName: "expresso-ts-adapter-express-coverage",
15+
uploadToken: process.env.CODECOV_TOKEN,
16+
}),
17+
],
18+
test: {
19+
globals: true,
20+
environment: "node",
21+
setupFiles: ["reflect-metadata"],
22+
exclude: ["**/node_modules/**", "**/test/**", "**/lib/**"],
23+
coverage: {
24+
all: true,
25+
include: ["**/src/**"],
26+
exclude: ["**/node_modules/**", "**/lib/**", "**/test/**", "**/index.ts/**"],
27+
thresholds: {
28+
global: {
29+
statements: 85,
30+
branches: 85,
31+
functions: 85,
32+
lines: 85,
33+
},
34+
},
35+
reporter: ["text", "html", "json"],
36+
provider: "v8",
37+
},
38+
// ref: https://vitest.dev/config/#testtimeout
39+
testTimeout: 10000,
40+
},
41+
});

0 commit comments

Comments
 (0)