MCPcopy
hub / github.com/forwardemail/supertest / end

Method end

lib/test.js:133–160  ·  view source on GitHub ↗

* Defer invoking superagent's `.end()` until * the server is listening. * * @param {?Function} fn * @api public

(fn)

Source from the content-addressed store, hash-verified

131 * @api public
132 */
133 end(fn) {
134 const server = this._server;
135
136 super.end((err, res) => {
137 const localAssert = () => {
138 this.assert(err, res, fn);
139 };
140
141 if (server && server._handle) {
142 // Handle server closing with error handling for already closed servers
143 return server.close((closeError) => {
144 // Ignore ERR_SERVER_NOT_RUNNING errors as the server is already closed
145 if (closeError && closeError.code === 'ERR_SERVER_NOT_RUNNING') {
146 return localAssert();
147 }
148 // For other errors, pass them through
149 if (closeError) {
150 return localAssert();
151 }
152 localAssert();
153 });
154 }
155
156 localAssert();
157 });
158
159 return this;
160 }
161
162 /**
163 * Perform assertions and invoke `fn(err, res)`.

Callers 5

expectMethod · 0.95
issue-fixes.jsFile · 0.80
supertest.jsFile · 0.80
appFunction · 0.80
cookies.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected