@@ -569,33 +569,68 @@ for (const { expectedRuntime, isNodeMiddleware, label, testWithSwitchableMiddlew
569569 if ( isNodeMiddleware ) {
570570 // Node.js Middleware specific tests to test features not available in Edge Runtime
571571 test . describe ( 'Node.js Middleware specific' , ( ) => {
572- test ( 'node:crypto module' , async ( { middlewareNodeRuntimeSpecific } ) => {
573- const response = await fetch ( `${ middlewareNodeRuntimeSpecific . url } /test/crypto` )
574- expect ( response . status ) . toBe ( 200 )
575- const body = await response . json ( )
576- expect (
577- body . random ,
578- 'random should have 16 random bytes generated with `randomBytes` function from node:crypto in hex format' ,
579- ) . toMatch ( / [ 0 - 9 a - f ] { 32 } / )
580- } )
572+ test . describe ( 'npm package manager' , ( ) => {
573+ test ( 'node:crypto module' , async ( { middlewareNodeRuntimeSpecific } ) => {
574+ const response = await fetch ( `${ middlewareNodeRuntimeSpecific . url } /test/crypto` )
575+ expect ( response . status ) . toBe ( 200 )
576+ const body = await response . json ( )
577+ expect (
578+ body . random ,
579+ 'random should have 16 random bytes generated with `randomBytes` function from node:crypto in hex format' ,
580+ ) . toMatch ( / [ 0 - 9 a - f ] { 32 } / )
581+ } )
581582
582- test ( 'node:http(s) module' , async ( { middlewareNodeRuntimeSpecific } ) => {
583- const response = await fetch ( `${ middlewareNodeRuntimeSpecific . url } /test/http` )
584- expect ( response . status ) . toBe ( 200 )
585- const body = await response . json ( )
586- expect (
587- body . proxiedWithHttpRequest ,
588- 'proxiedWithHttpRequest should be the result of `http.request` from node:http fetching static asset' ,
589- ) . toStrictEqual ( { hello : 'world' } )
583+ test ( 'node:http(s) module' , async ( { middlewareNodeRuntimeSpecific } ) => {
584+ const response = await fetch ( `${ middlewareNodeRuntimeSpecific . url } /test/http` )
585+ expect ( response . status ) . toBe ( 200 )
586+ const body = await response . json ( )
587+ expect (
588+ body . proxiedWithHttpRequest ,
589+ 'proxiedWithHttpRequest should be the result of `http.request` from node:http fetching static asset' ,
590+ ) . toStrictEqual ( { hello : 'world' } )
591+ } )
592+
593+ test ( 'node:path module' , async ( { middlewareNodeRuntimeSpecific } ) => {
594+ const response = await fetch ( `${ middlewareNodeRuntimeSpecific . url } /test/path` )
595+ expect ( response . status ) . toBe ( 200 )
596+ const body = await response . json ( )
597+ expect (
598+ body . joined ,
599+ 'joined should be the result of `join` function from node:path' ,
600+ ) . toBe ( 'a/b' )
601+ } )
590602 } )
591603
592- test ( 'node:path module' , async ( { middlewareNodeRuntimeSpecific } ) => {
593- const response = await fetch ( `${ middlewareNodeRuntimeSpecific . url } /test/path` )
594- expect ( response . status ) . toBe ( 200 )
595- const body = await response . json ( )
596- expect ( body . joined , 'joined should be the result of `join` function from node:path' ) . toBe (
597- 'a/b' ,
598- )
604+ test . describe ( 'pnpm package manager' , ( ) => {
605+ test ( 'node:crypto module' , async ( { middlewareNodeRuntimeSpecificPnpm } ) => {
606+ const response = await fetch ( `${ middlewareNodeRuntimeSpecificPnpm . url } /test/crypto` )
607+ expect ( response . status ) . toBe ( 200 )
608+ const body = await response . json ( )
609+ expect (
610+ body . random ,
611+ 'random should have 16 random bytes generated with `randomBytes` function from node:crypto in hex format' ,
612+ ) . toMatch ( / [ 0 - 9 a - f ] { 32 } / )
613+ } )
614+
615+ test ( 'node:http(s) module' , async ( { middlewareNodeRuntimeSpecificPnpm } ) => {
616+ const response = await fetch ( `${ middlewareNodeRuntimeSpecificPnpm . url } /test/http` )
617+ expect ( response . status ) . toBe ( 200 )
618+ const body = await response . json ( )
619+ expect (
620+ body . proxiedWithHttpRequest ,
621+ 'proxiedWithHttpRequest should be the result of `http.request` from node:http fetching static asset' ,
622+ ) . toStrictEqual ( { hello : 'world' } )
623+ } )
624+
625+ test ( 'node:path module' , async ( { middlewareNodeRuntimeSpecificPnpm } ) => {
626+ const response = await fetch ( `${ middlewareNodeRuntimeSpecificPnpm . url } /test/path` )
627+ expect ( response . status ) . toBe ( 200 )
628+ const body = await response . json ( )
629+ expect (
630+ body . joined ,
631+ 'joined should be the result of `join` function from node:path' ,
632+ ) . toBe ( 'a/b' )
633+ } )
599634 } )
600635 } )
601636 }
0 commit comments