@@ -8,45 +8,55 @@ import path from "node:path";
88let request ;
99let server ;
1010
11- // Start server before running tests
12- test . before ( async ( t ) => {
13- process . env [ "NODE_TLS_REJECT_UNAUTHORIZED" ] = "0" ;
11+ const nodeVersion = parseInt ( process . versions . node . split ( "." ) [ 0 ] , 10 ) ;
1412
15- const graph = await graphFromPackageDependencies ( {
16- cwd : "./test/fixtures/application.a"
17- } ) ;
18- const sslPath = path . join ( process . cwd ( ) , "./test/fixtures/ssl/" ) ;
19- const { key, cert} = await getSslCertificate (
20- path . join ( sslPath , "server.key" ) ,
21- path . join ( sslPath , "server.crt" ) ,
22- ) ;
23- server = await serve ( graph , {
24- port : 3366 ,
25- h2 : true ,
26- key,
27- cert
13+ if ( nodeVersion < 24 ) {
14+ // Start server before running tests
15+ test . before ( async ( t ) => {
16+ process . env [ "NODE_TLS_REJECT_UNAUTHORIZED" ] = "0" ;
17+
18+ const graph = await graphFromPackageDependencies ( {
19+ cwd : "./test/fixtures/application.a"
20+ } ) ;
21+ const sslPath = path . join ( process . cwd ( ) , "./test/fixtures/ssl/" ) ;
22+ const { key, cert} = await getSslCertificate (
23+ path . join ( sslPath , "server.key" ) ,
24+ path . join ( sslPath , "server.crt" ) ,
25+ ) ;
26+ server = await serve ( graph , {
27+ port : 3366 ,
28+ h2 : true ,
29+ key,
30+ cert
31+ } ) ;
32+ request = supertest ( "https://localhost:3366" ) ;
2833 } ) ;
29- request = supertest ( "https://localhost:3366" ) ;
30- } ) ;
3134
32- test . after ( ( ) => {
33- return new Promise ( ( resolve , reject ) => {
34- server . close ( ( error ) => {
35- if ( error ) {
36- reject ( error ) ;
37- } else {
38- resolve ( ) ;
39- }
35+ test . after ( ( ) => {
36+ return new Promise ( ( resolve , reject ) => {
37+ server . close ( ( error ) => {
38+ if ( error ) {
39+ reject ( error ) ;
40+ } else {
41+ resolve ( ) ;
42+ }
43+ } ) ;
4044 } ) ;
4145 } ) ;
42- } ) ;
4346
44- test ( "Get resource from application.a (/index.html)" , async ( t ) => {
45- const res = await request . get ( "/index.html" ) ;
46- if ( res . error ) {
47- t . fail ( res . error . text ) ;
48- }
49- t . is ( res . statusCode , 200 , "Correct HTTP status code" ) ;
50- t . regex ( res . headers [ "content-type" ] , / h t m l / , "Correct content type" ) ;
51- t . regex ( res . text , / < t i t l e > A p p l i c a t i o n A < \/ t i t l e > / , "Correct response" ) ;
52- } ) ;
47+ test ( "Get resource from application.a (/index.html)" , async ( t ) => {
48+ const res = await request . get ( "/index.html" ) ;
49+ if ( res . error ) {
50+ t . fail ( res . error . text ) ;
51+ }
52+ t . is ( res . statusCode , 200 , "Correct HTTP status code" ) ;
53+ t . regex ( res . headers [ "content-type" ] , / h t m l / , "Correct content type" ) ;
54+ t . regex ( res . text , / < t i t l e > A p p l i c a t i o n A < \/ t i t l e > / , "Correct response" ) ;
55+ } ) ;
56+ } else {
57+ test ( "HTTP Parser is missing" , async ( t ) => {
58+ await t . throwsAsync ( async ( ) => {
59+ await import ( "spdy" ) ;
60+ } ) ;
61+ } ) ;
62+ }
0 commit comments