1
1
import { describe , beforeAll , afterEach , expect , test , vi } from "vitest" ;
2
2
import { createServer } from "node:http" ;
3
3
import { readFileSync } from "node:fs" ;
4
+ import type { AddressInfo } from "node:net" ;
4
5
5
6
import { sign } from "@octokit/webhooks-methods" ;
6
7
@@ -38,8 +39,7 @@ describe("createNodeMiddleware(webhooks)", () => {
38
39
39
40
const server = createServer ( createNodeMiddleware ( webhooks ) ) . listen ( ) ;
40
41
41
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
42
- const { port } = server . address ( ) ;
42
+ const { port } = server . address ( ) as AddressInfo ;
43
43
44
44
const response = await fetch (
45
45
`http://localhost:${ port } /api/github/webhooks` ,
@@ -83,8 +83,7 @@ describe("createNodeMiddleware(webhooks)", () => {
83
83
expect ( event . id ) . toBe ( "123e4567-e89b-12d3-a456-426655440000" ) ;
84
84
} ) ;
85
85
86
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
87
- const { port } = server . address ( ) ;
86
+ const { port } = server . address ( ) as AddressInfo ;
88
87
89
88
const response = await fetch (
90
89
`http://localhost:${ port } /api/github/webhooks` ,
@@ -113,8 +112,7 @@ describe("createNodeMiddleware(webhooks)", () => {
113
112
114
113
const server = createServer ( createNodeMiddleware ( webhooks ) ) . listen ( ) ;
115
114
116
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
117
- const { port } = server . address ( ) ;
115
+ const { port } = server . address ( ) as AddressInfo ;
118
116
const response = await fetch (
119
117
`http://localhost:${ port } /api/github/webhooks` ,
120
118
{
@@ -144,8 +142,7 @@ describe("createNodeMiddleware(webhooks)", () => {
144
142
145
143
const server = createServer ( createNodeMiddleware ( webhooks ) ) . listen ( ) ;
146
144
147
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
148
- const { port } = server . address ( ) ;
145
+ const { port } = server . address ( ) as AddressInfo ;
149
146
const response = await fetch (
150
147
`http://localhost:${ port } /api/github/webhooks` ,
151
148
{
@@ -174,8 +171,7 @@ describe("createNodeMiddleware(webhooks)", () => {
174
171
175
172
const server = createServer ( createNodeMiddleware ( webhooks ) ) . listen ( ) ;
176
173
177
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
178
- const { port } = server . address ( ) ;
174
+ const { port } = server . address ( ) as AddressInfo ;
179
175
180
176
const payload = '{"name":"invalid"' ;
181
177
@@ -207,8 +203,7 @@ describe("createNodeMiddleware(webhooks)", () => {
207
203
208
204
const server = createServer ( createNodeMiddleware ( webhooks ) ) . listen ( ) ;
209
205
210
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
211
- const { port } = server . address ( ) ;
206
+ const { port } = server . address ( ) as AddressInfo ;
212
207
213
208
const response = await fetch (
214
209
`http://localhost:${ port } /api/github/webhooks` ,
@@ -247,8 +242,7 @@ describe("createNodeMiddleware(webhooks)", () => {
247
242
}
248
243
} ) . listen ( ) ;
249
244
250
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
251
- const { port } = server . address ( ) ;
245
+ const { port } = server . address ( ) as AddressInfo ;
252
246
253
247
const response = await fetch ( `http://localhost:${ port } /foo` , {
254
248
method : "PUT" ,
@@ -274,8 +268,7 @@ describe("createNodeMiddleware(webhooks)", () => {
274
268
275
269
const server = createServer ( createNodeMiddleware ( webhooks ) ) . listen ( ) ;
276
270
277
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
278
- const { port } = server . address ( ) ;
271
+ const { port } = server . address ( ) as AddressInfo ;
279
272
280
273
const response = await fetch (
281
274
`http://localhost:${ port } /api/github/webhooks` ,
@@ -311,8 +304,7 @@ describe("createNodeMiddleware(webhooks)", () => {
311
304
312
305
const server = createServer ( createNodeMiddleware ( webhooks ) ) . listen ( ) ;
313
306
314
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
315
- const { port } = server . address ( ) ;
307
+ const { port } = server . address ( ) as AddressInfo ;
316
308
317
309
const response = await fetch (
318
310
`http://localhost:${ port } /api/github/webhooks` ,
@@ -345,8 +337,7 @@ describe("createNodeMiddleware(webhooks)", () => {
345
337
346
338
const server = createServer ( createNodeMiddleware ( webhooks ) ) . listen ( ) ;
347
339
348
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
349
- const { port } = server . address ( ) ;
340
+ const { port } = server . address ( ) as AddressInfo ;
350
341
351
342
const response = await fetch (
352
343
`http://localhost:${ port } /api/github/webhooks` ,
@@ -384,8 +375,7 @@ describe("createNodeMiddleware(webhooks)", () => {
384
375
385
376
const server = createServer ( createNodeMiddleware ( webhooks ) ) . listen ( ) ;
386
377
387
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
388
- const { port } = server . address ( ) ;
378
+ const { port } = server . address ( ) as AddressInfo ;
389
379
390
380
const response = await fetch (
391
381
`http://localhost:${ port } /api/github/webhooks` ,
@@ -420,8 +410,7 @@ describe("createNodeMiddleware(webhooks)", () => {
420
410
421
411
const server = createServer ( createNodeMiddleware ( webhooks ) ) . listen ( ) ;
422
412
423
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
424
- const { port } = server . address ( ) ;
413
+ const { port } = server . address ( ) as AddressInfo ;
425
414
426
415
const response = await fetch (
427
416
`http://localhost:${ port } /api/github/webhooks` ,
@@ -582,8 +571,7 @@ describe("createNodeMiddleware(webhooks)", () => {
582
571
} ;
583
572
const server = createServer ( mockedMiddleware ) . listen ( ) ;
584
573
585
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
586
- const { port } = server . address ( ) ;
574
+ const { port } = server . address ( ) as AddressInfo ;
587
575
588
576
const response = await fetch (
589
577
`http://localhost:${ port } /api/github/webhooks` ,
@@ -628,8 +616,7 @@ describe("createNodeMiddleware(webhooks)", () => {
628
616
const middleware = createNodeMiddleware ( webhooks , { log } ) ;
629
617
const server = createServer ( middleware ) . listen ( ) ;
630
618
631
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
632
- const { port } = server . address ( ) ;
619
+ const { port } = server . address ( ) as AddressInfo ;
633
620
634
621
const response = await fetch (
635
622
`http://localhost:${ port } /api/github/webhooks` ,
@@ -678,8 +665,7 @@ test("request.body is already an Object and has request.rawBody as Buffer (e.g.
678
665
expect ( event . id ) . toBe ( "123e4567-e89b-12d3-a456-426655440000" ) ;
679
666
} ) ;
680
667
681
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
682
- const { port } = server . address ( ) ;
668
+ const { port } = server . address ( ) as AddressInfo ;
683
669
684
670
const response = await fetch ( `http://localhost:${ port } /api/github/webhooks` , {
685
671
method : "POST" ,
0 commit comments