endpoint-coverage
Provides a way to collect API endpoint test coverage in your API tests.
Installation
Via NPM
$ npm install endpoint-coverage --save-dev
Usage
There is one main function exported in the module, coverageMiddleware
.
coverageMiddleware
Express.js middleware that collects all HTTP requests made against the server. Scans all request handlers registered in the application and pre-attaches middleware checking whether the given handler was called.
Registers endpoint (GET /collectCoverage
) for collecting the coverage.
Middleware has to be registered only in the test environment.
Example
server.ts
;; ;; ifisTestEnv app.get'/path/:param',;app.post'/anotherPath',; return app.listenport;
afterTest.ts
; afterAll;