@@ -73,7 +73,7 @@ You can also instrument your server-side code and produce combined coverage repo
7373``` js
7474const express = require (' express' )
7575const app = express ()
76- require (' @cypress/code-coverage/middleware' )(app)
76+ require (' @cypress/code-coverage/middleware/express ' )(app)
7777```
7878
7979** Tip:** you can register the endpoint only if there is global code coverage object, and you can exclude the middleware code from the coverage numbers
@@ -82,24 +82,25 @@ require('@cypress/code-coverage/middleware')(app)
8282// https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md
8383/* istanbul ignore next */
8484if (global .__coverage__ ) {
85- require (' @cypress/code-coverage/middleware' )(app)
85+ require (' @cypress/code-coverage/middleware/express ' )(app)
8686}
8787```
8888
8989If you use Hapi server, define the endpoint yourself and return the object
9090
9191``` js
92- // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md
93- /* istanbul ignore next */
9492if (global .__coverage__ ) {
95- // https://hapijs.com/tutorials/routing?lang=en_US
96- server .route ({
97- method: ' GET' ,
98- path: ' /__coverage__' ,
99- handler () {
100- return { coverage: global .__coverage__ }
101- }
102- })
93+ require (' @cypress/code-coverage/middleware/hapi' )(server)
94+ }
95+ ```
96+
97+ For any other server, define the endpoint yourself and return the coverage object:
98+
99+ ``` js
100+ if (global .__coverage__ ) {
101+ // add method "GET /__coverage__" and response with JSON
102+ onRequest = (response ) =>
103+ response .sendJSON ({coverage: global .__coverage__ })
103104}
104105```
105106
0 commit comments