Skip to content

Commit def5a13

Browse files
feat: update types for api-coverage and readme doc
Co-authored-by: Valentin L [email protected]
1 parent f355d85 commit def5a13

File tree

11 files changed

+965
-525
lines changed

11 files changed

+965
-525
lines changed

fixtures/fixture.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import config from '../config.json' with { type: 'json' }
55
export { expect } from '@playwright/test'
66
const apiCoverage = new ApiCoverage(config)
77
await apiCoverage.loadSpec('https://parabank.parasoft.com/parabank/services/bank/openapi.yaml')
8-
apiCoverage.setDebug(false)
8+
apiCoverage.setDebug(true, 'error')
99

1010
const extension = {
1111
testHook: [

package-lock.json

Lines changed: 525 additions & 403 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "2.0.3",
44
"description": "A universal library for tracking API coverage against OpenAPI/Swagger specifications from URL or local file. Supports Axis, Fetch, Playwright and manual registry of the responses",
55
"main": "./utils/api-coverage.js",
6+
"types": "./utils/api-coverage.d.ts",
67
"exports": {
78
".": "./utils/api-coverage.js"
89
},
@@ -14,7 +15,8 @@
1415
"test-axios": "node e2e/api-coverage-example.js",
1516
"test-playwright": "npx playwright test",
1617
"test-postman": "npx api-coverage-tracker --spec 'https://fakestoreapi.com/docs-data' --collection './e2e/data/FakeStoreAPI.postman_collection.json' --coverage detailed",
17-
"lint": "eslint ."
18+
"lint": "eslint .",
19+
"bump": "npx -y npm-check-updates -u && npm prune"
1820
},
1921
"keywords": [
2022
"api",
@@ -37,17 +39,17 @@
3739
},
3840
"homepage": "https://github.com/Valiantsin2021/api-coverage-tracker#readme",
3941
"dependencies": {
40-
"@apidevtools/swagger-parser": "^10.1.1"
42+
"@apidevtools/swagger-parser": "^12.1.0"
4143
},
4244
"devDependencies": {
43-
"@playwright/test": "^1.51.1",
44-
"eslint": "^9.24.0",
45-
"eslint-config-prettier": "^10.1.2",
46-
"eslint-plugin-jsdoc": "^50.6.9",
45+
"@playwright/test": "^1.57.0",
46+
"eslint": "^9.39.2",
47+
"eslint-config-prettier": "^10.1.8",
48+
"eslint-plugin-jsdoc": "^62.1.0",
4749
"eslint-plugin-no-floating-promise": "^2.0.0",
48-
"eslint-plugin-playwright": "2.2.0",
49-
"prettier": "^3.5.3",
50-
"axios": "^1.8.4"
50+
"eslint-plugin-playwright": "2.5.0",
51+
"prettier": "^3.8.0",
52+
"axios": "^1.13.2"
5153
},
5254
"engines": {
5355
"node": ">=18.0.0"

readme.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,42 @@ For Postman collections it also tracks the previous coverage statistics. Support
6060
```bash
6161
npm install -D api-coverage-tracker
6262
```
63+
64+
## TypeScript Support
65+
66+
This library includes TypeScript definitions for full auto-completion support. When using in TypeScript projects, you'll get:
67+
68+
- Auto-completion for all methods and properties
69+
- Type checking for method parameters and return values
70+
- IntelliSense for configuration objects and options
71+
72+
```typescript
73+
import { ApiCoverage, ApiCoverageConfig, StartTrackingOptions } from 'api-coverage-tracker';
74+
75+
const config: ApiCoverageConfig = {
76+
services: [{
77+
key: 'my-api',
78+
name: 'My API',
79+
tags: ['api'],
80+
repository: 'https://github.com/myorg/my-api',
81+
swaggerUrl: 'https://api.example.com/swagger.json'
82+
}],
83+
'report-path': './reports'
84+
};
85+
86+
const apiCoverage = new ApiCoverage(config);
87+
88+
// Full auto-completion available
89+
await apiCoverage.loadSpec('https://api.example.com/swagger.json');
90+
91+
const options: StartTrackingOptions = {
92+
clientType: 'axios',
93+
coverage: 'detailed'
94+
};
95+
96+
await apiCoverage.startTracking(axiosInstance, options);
97+
```
98+
6399
## Configuration
64100

65101
The library requires a configuration object with service information:

reports/Parabankapiservice.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,13 @@
66
{
77
"createdAt": "2025-06-09T12:52:40.454Z",
88
"totalCoverage": 100
9+
},
10+
{
11+
"createdAt": "2025-11-22T21:25:16.153Z",
12+
"totalCoverage": 100
13+
},
14+
{
15+
"createdAt": "2026-01-25T20:25:47.897Z",
16+
"totalCoverage": 100
917
}
1018
]

reports/Petsplaywrightapiservice.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
{
33
"createdAt": "2025-06-08T23:13:51.655Z",
44
"totalCoverage": 56
5+
},
6+
{
7+
"createdAt": "2026-01-18T19:25:40.391Z",
8+
"totalCoverage": 56
59
}
610
]

reports/history.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
"method": "GET",
203203
"path": "/pet/findByStatus",
204204
"statuses": {
205-
"200": 2
205+
"200": 1
206206
},
207207
"queryParams": [
208208
"status"
@@ -512,15 +512,17 @@
512512
"method": "GET",
513513
"path": "/accounts/{accountId}",
514514
"statuses": {
515-
"200": 1
515+
"200": 1,
516+
"400": 1
516517
},
517518
"queryParams": []
518519
},
519520
{
520521
"method": "GET",
521522
"path": "/accounts/{accountId}/transactions",
522523
"statuses": {
523-
"200": 3
524+
"200": 3,
525+
"400": 1
524526
},
525527
"queryParams": [
526528
"amount",

0 commit comments

Comments
 (0)