Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fixtures/fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import config from '../config.json' with { type: 'json' }
export { expect } from '@playwright/test'
const apiCoverage = new ApiCoverage(config)
await apiCoverage.loadSpec('https://parabank.parasoft.com/parabank/services/bank/openapi.yaml')
apiCoverage.setDebug(false)
apiCoverage.setDebug(true, 'error')

const extension = {
testHook: [
Expand Down
928 changes: 525 additions & 403 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "2.0.3",
"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",
"main": "./utils/api-coverage.js",
"types": "./utils/api-coverage.d.ts",
"exports": {
".": "./utils/api-coverage.js"
},
Expand All @@ -14,7 +15,8 @@
"test-axios": "node e2e/api-coverage-example.js",
"test-playwright": "npx playwright test",
"test-postman": "npx api-coverage-tracker --spec 'https://fakestoreapi.com/docs-data' --collection './e2e/data/FakeStoreAPI.postman_collection.json' --coverage detailed",
"lint": "eslint ."
"lint": "eslint .",
"bump": "npx -y npm-check-updates -u && npm prune"
},
"keywords": [
"api",
Expand All @@ -37,17 +39,17 @@
},
"homepage": "https://github.com/Valiantsin2021/api-coverage-tracker#readme",
"dependencies": {
"@apidevtools/swagger-parser": "^10.1.1"
"@apidevtools/swagger-parser": "^12.1.0"
},
"devDependencies": {
"@playwright/test": "^1.51.1",
"eslint": "^9.24.0",
"eslint-config-prettier": "^10.1.2",
"eslint-plugin-jsdoc": "^50.6.9",
"@playwright/test": "^1.57.0",
"eslint": "^9.39.2",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-jsdoc": "^62.1.0",
"eslint-plugin-no-floating-promise": "^2.0.0",
"eslint-plugin-playwright": "2.2.0",
"prettier": "^3.5.3",
"axios": "^1.8.4"
"eslint-plugin-playwright": "2.5.0",
"prettier": "^3.8.0",
"axios": "^1.13.2"
},
"engines": {
"node": ">=18.0.0"
Expand Down
36 changes: 36 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,42 @@ For Postman collections it also tracks the previous coverage statistics. Support
```bash
npm install -D api-coverage-tracker
```

## TypeScript Support

This library includes TypeScript definitions for full auto-completion support. When using in TypeScript projects, you'll get:

- Auto-completion for all methods and properties
- Type checking for method parameters and return values
- IntelliSense for configuration objects and options

```typescript
import { ApiCoverage, ApiCoverageConfig, StartTrackingOptions } from 'api-coverage-tracker';

const config: ApiCoverageConfig = {
services: [{
key: 'my-api',
name: 'My API',
tags: ['api'],
repository: 'https://github.com/myorg/my-api',
swaggerUrl: 'https://api.example.com/swagger.json'
}],
'report-path': './reports'
};

const apiCoverage = new ApiCoverage(config);

// Full auto-completion available
await apiCoverage.loadSpec('https://api.example.com/swagger.json');

const options: StartTrackingOptions = {
clientType: 'axios',
coverage: 'detailed'
};

await apiCoverage.startTracking(axiosInstance, options);
```

## Configuration

The library requires a configuration object with service information:
Expand Down
8 changes: 8 additions & 0 deletions reports/Parabankapiservice.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,13 @@
{
"createdAt": "2025-06-09T12:52:40.454Z",
"totalCoverage": 100
},
{
"createdAt": "2025-11-22T21:25:16.153Z",
"totalCoverage": 100
},
{
"createdAt": "2026-01-25T20:25:47.897Z",
"totalCoverage": 100
}
]
4 changes: 4 additions & 0 deletions reports/Petsplaywrightapiservice.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
{
"createdAt": "2025-06-08T23:13:51.655Z",
"totalCoverage": 56
},
{
"createdAt": "2026-01-18T19:25:40.391Z",
"totalCoverage": 56
}
]
8 changes: 5 additions & 3 deletions reports/history.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
"method": "GET",
"path": "/pet/findByStatus",
"statuses": {
"200": 2
"200": 1
},
"queryParams": [
"status"
Expand Down Expand Up @@ -512,15 +512,17 @@
"method": "GET",
"path": "/accounts/{accountId}",
"statuses": {
"200": 1
"200": 1,
"400": 1
},
"queryParams": []
},
{
"method": "GET",
"path": "/accounts/{accountId}/transactions",
"statuses": {
"200": 3
"200": 3,
"400": 1
},
"queryParams": [
"amount",
Expand Down
Loading
Loading