@@ -8,45 +8,57 @@ import path from "node:path";
8
8
let request ;
9
9
let server ;
10
10
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 ) ;
14
12
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
+ // Withe Node.js 24 and later, the HTTP parser is missing, which breaks the HTTP/2 support in the spdy package.
14
+ // Tests need to be NodeJs version agnostic.
15
+ if ( nodeVersion < 24 ) {
16
+ // Start server before running tests
17
+ test . before ( async ( t ) => {
18
+ process . env [ "NODE_TLS_REJECT_UNAUTHORIZED" ] = "0" ;
19
+
20
+ const graph = await graphFromPackageDependencies ( {
21
+ cwd : "./test/fixtures/application.a"
22
+ } ) ;
23
+ const sslPath = path . join ( process . cwd ( ) , "./test/fixtures/ssl/" ) ;
24
+ const { key, cert} = await getSslCertificate (
25
+ path . join ( sslPath , "server.key" ) ,
26
+ path . join ( sslPath , "server.crt" ) ,
27
+ ) ;
28
+ server = await serve ( graph , {
29
+ port : 3366 ,
30
+ h2 : true ,
31
+ key,
32
+ cert
33
+ } ) ;
34
+ request = supertest ( "https://localhost:3366" ) ;
28
35
} ) ;
29
- request = supertest ( "https://localhost:3366" ) ;
30
- } ) ;
31
36
32
- test . after ( ( ) => {
33
- return new Promise ( ( resolve , reject ) => {
34
- server . close ( ( error ) => {
35
- if ( error ) {
36
- reject ( error ) ;
37
- } else {
38
- resolve ( ) ;
39
- }
37
+ test . after ( ( ) => {
38
+ return new Promise ( ( resolve , reject ) => {
39
+ server . close ( ( error ) => {
40
+ if ( error ) {
41
+ reject ( error ) ;
42
+ } else {
43
+ resolve ( ) ;
44
+ }
45
+ } ) ;
40
46
} ) ;
41
47
} ) ;
42
- } ) ;
43
48
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
- } ) ;
49
+ test ( "Get resource from application.a (/index.html)" , async ( t ) => {
50
+ const res = await request . get ( "/index.html" ) ;
51
+ if ( res . error ) {
52
+ t . fail ( res . error . text ) ;
53
+ }
54
+ t . is ( res . statusCode , 200 , "Correct HTTP status code" ) ;
55
+ t . regex ( res . headers [ "content-type" ] , / h t m l / , "Correct content type" ) ;
56
+ 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" ) ;
57
+ } ) ;
58
+ } else {
59
+ test ( "HTTP Parser is missing" , async ( t ) => {
60
+ await t . throwsAsync ( async ( ) => {
61
+ await import ( "spdy" ) ;
62
+ } ) ;
63
+ } ) ;
64
+ }
0 commit comments