File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,9 @@ const handleError = (
6868 deferredReject : ( ( e : unknown ) => unknown ) | null
6969) => {
7070 // ? Prevent tests that crash the server from hanging
71- ! res . writableEnded && res . end ( ) ;
71+ if ( ! res . writableEnded ) {
72+ res . end ( ) ;
73+ }
7274
7375 // ? Throwing at the point this function was called would not normally cause
7476 // ? testApiHandler to reject because createServer (an EventEmitter) only
@@ -204,12 +206,16 @@ export async function testApiHandler<NextResponseJsonType = any>({
204206 ) ;
205207 }
206208
207- url && ( req . url = url ) ;
208- requestPatcher && requestPatcher ( req ) ;
209- responsePatcher && responsePatcher ( res ) ;
209+ if ( url ) {
210+ req . url = url ;
211+ }
212+
213+ requestPatcher ?.( req ) ;
214+ responsePatcher ?.( res ) ;
210215
211216 const finalParams = { ...parseUrl ( req . url || '' , true ) . query , ...params } ;
212- paramsPatcher && paramsPatcher ( finalParams ) ;
217+
218+ paramsPatcher ?.( finalParams ) ;
213219
214220 /**
215221 *? From Next.js internals:
@@ -220,7 +226,8 @@ export async function testApiHandler<NextResponseJsonType = any>({
220226 ** resolverModule: any,
221227 ** apiContext: __ApiPreviewProps,
222228 ** propagateError: boolean,
223- ** ...
229+ ** dev?: boolean,
230+ ** page?: boolean
224231 ** )
225232 */
226233 void apiResolver (
You can’t perform that action at this time.
0 commit comments