@@ -67,7 +67,6 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
67
67
onSpawn : ( process ) => {
68
68
pid = process . pid ;
69
69
} ,
70
- printOutput : true ,
71
70
}
72
71
) ;
73
72
expect ( pid ) . toBeDefined ( ) ;
@@ -105,7 +104,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
105
104
return Response.json({ ok: req.url })
106
105
} }
107
106
` ,
108
- { printOutput : true }
107
+ { printOutput : false }
109
108
) ;
110
109
const json = await jsonRequest ( worker , "https://localhost/hello?isee=you" , {
111
110
headers : { accept : "application/json" } ,
@@ -127,7 +126,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
127
126
return Response.json({ ok: req.url, headers: headers })
128
127
} }
129
128
` ,
130
- { printOutput : true }
129
+ { printOutput : false }
131
130
) ;
132
131
for ( let i = 0 ; i < 10 ; i ++ ) {
133
132
const json = await jsonRequest (
@@ -152,7 +151,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
152
151
return Response.json({ error: error.message }, { status: 500 })
153
152
}}
154
153
` ,
155
- { printOutput : true }
154
+ { printOutput : false }
156
155
) ;
157
156
const json = await jsonRequest ( worker , "https://localhost/hello?isee=you" , {
158
157
headers : { accept : "application/json" } ,
@@ -228,7 +227,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
228
227
return Response.json({ ok: req.url })
229
228
}}
230
229
` ,
231
- { printOutput : true }
230
+ { printOutput : false }
232
231
) ;
233
232
234
233
let logs = "" ;
@@ -243,11 +242,9 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
243
242
} ) ;
244
243
} ) ;
245
244
const json = await jsonRequest ( worker , "https://localhost/hello?isee=you" ) ;
246
- console . log ( json ) ;
247
245
expect ( json ) . toEqual ( {
248
246
ok : "https://localhost/hello?isee=you" ,
249
247
} ) ;
250
- console . log ( "OKK" ) ;
251
248
void worker . shutdown ( ) ;
252
249
await exitPromise ;
253
250
} ) ;
@@ -262,7 +259,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
262
259
"--allow-write=bar,/dev/null" ,
263
260
] ) ( "should handle %s" , async ( flag ) => {
264
261
const worker = await newDenoHTTPWorker ( echoScript , {
265
- printOutput : true ,
262
+ printOutput : false ,
266
263
runFlags : [ flag ] ,
267
264
} ) ;
268
265
await jsonRequest ( worker , "http://localhost" ) ;
@@ -274,8 +271,8 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
274
271
const file = path . resolve ( __dirname , "./test/echo-request.ts" ) ;
275
272
const url = new URL ( `file://${ file } ` ) ;
276
273
const worker = await newDenoHTTPWorker ( url , {
277
- printOutput : true ,
278
- printCommandAndArguments : true ,
274
+ printOutput : false ,
275
+ printCommandAndArguments : false ,
279
276
} ) ;
280
277
281
278
await jsonRequest ( worker , "http://localhost" ) ;
@@ -284,7 +281,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
284
281
285
282
it ( "host and connection is not overwritten" , async ( ) => {
286
283
const worker = await newDenoHTTPWorker ( echoScript , {
287
- printOutput : true ,
284
+ printOutput : false ,
288
285
} ) ;
289
286
const resp : any = await jsonRequest ( worker , "https://localhost/" , {
290
287
headers : {
@@ -317,14 +314,12 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
317
314
318
315
await new Promise ( ( resolve ) => setTimeout ( resolve , 300 ) ) ;
319
316
320
- const t0 = performance . now ( ) ;
321
317
const resp = await worker . request ( {
322
318
url : "http://localhost/hi" ,
323
319
method : "GET" ,
324
320
} ) ;
325
321
const json = await resp . body . json ( ) ;
326
322
327
- console . log ( "http request time" , performance . now ( ) - t0 ) ;
328
323
expect ( json ) . toEqual ( {
329
324
url : "http://localhost/hi" ,
330
325
headers : { } ,
@@ -337,7 +332,6 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
337
332
it ( "can implement val town with http.request" , async ( ) => {
338
333
const worker = await newDenoHTTPWorker ( vtScript , { printOutput : true } ) ;
339
334
340
- const t0 = performance . now ( ) ;
341
335
await worker . request ( {
342
336
url : "http://vt/" ,
343
337
method : "POST" ,
@@ -355,31 +349,10 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
355
349
. then ( ( resp ) => resp . body . text ( ) ) ;
356
350
357
351
expect ( text ) . toEqual ( '{"ok":true}' ) ;
358
- console . log ( "Double request http2 val:" , performance . now ( ) - t0 ) ;
359
352
// await initReq;
360
353
await worker . terminate ( ) ;
361
354
} ) ;
362
355
363
- // it("val town import header", async () => {
364
- // const worker = await newDenoHTTPWorker(vtHeaderScript, { printOutput: true });
365
-
366
- // const t0 = performance.now();
367
- // const text = await worker.request({
368
- // url: "https://localhost:1234",
369
- // path: "/",
370
- // headers: {
371
- // "X-VT-Import": `data:text/tsx,${encodeURIComponent(
372
- // DEFAULT_HTTP_VAL
373
- // )}`,
374
- // },
375
- // }).then(resp => resp.body.text())
376
-
377
- // expect(text).toEqual('{"ok":true}');
378
- // console.log("single request:", performance.now() - t0);
379
- // // await initReq;
380
- // worker.terminate();
381
- // });
382
-
383
356
it ( "can test that snippets in readme run successfully" , async ( ) => {
384
357
const rm = fs . readFileSync ( path . resolve ( __dirname , "../README.md" ) , {
385
358
encoding : "utf-8" ,
@@ -391,7 +364,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
391
364
. map ( ( line ) => line . slice ( 3 ) ) ;
392
365
for ( let source of toTest ) {
393
366
source = source . replaceAll (
394
- " import { newDenoHTTPWorker } from ' deno-http-worker';" ,
367
+ ' import { newDenoHTTPWorker } from " deno-http-worker";' ,
395
368
"const { newDenoHTTPWorker } = await import('./dist/index.js'); "
396
369
) ;
397
370
source = `(async () => {${ source } })()` ;
@@ -400,18 +373,16 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
400
373
const worker = new Worker ( source , {
401
374
eval : true ,
402
375
} ) ;
403
- worker . stderr . on ( "data" , ( data ) => {
404
- console . error ( data . toString ( ) ) ;
376
+ worker . stderr . on ( "data" , ( _data ) => {
377
+ // console.error(data.toString());
405
378
} ) ;
406
- worker . stdout . on ( "data" , ( data ) => {
407
- console . error ( data . toString ( ) ) ;
379
+ worker . stdout . on ( "data" , ( _data ) => {
380
+ // console.error(data.toString());
408
381
} ) ;
409
382
worker . on ( "error" , ( e ) => {
410
- console . log ( e . stack ) ;
411
383
reject ( e ) ;
412
384
} ) ;
413
- worker . on ( "exit" , ( code ) => {
414
- console . log ( code ) ;
385
+ worker . on ( "exit" , ( _code ) => {
415
386
resolve ( ) ;
416
387
} ) ;
417
388
} ) ;
@@ -423,14 +394,13 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
423
394
encoding : "utf-8" ,
424
395
} ) ;
425
396
const worker = await newDenoHTTPWorker ( webSocketScriptStr , {
426
- printOutput : true ,
397
+ printOutput : false ,
427
398
} ) ;
428
399
429
400
const messages : string [ ] = [ ] ;
430
401
const ws = await worker . websocket ( "ws://localhost/echo" ) ;
431
402
const event = await new Promise < Event > ( ( res ) => {
432
403
ws . addEventListener ( "open" , ( event ) => {
433
- console . log ( "WebSocket connection opened" ) ;
434
404
ws . send ( "message1" ) ;
435
405
res ( event ) ;
436
406
} ) ;
@@ -463,7 +433,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
463
433
encoding : "utf-8" ,
464
434
} ) ;
465
435
const worker = await newDenoHTTPWorker ( webSocketScriptStr , {
466
- printOutput : true ,
436
+ printOutput : false ,
467
437
} ) ;
468
438
469
439
const ws1 = await worker . websocket ( "ws://localhost/echo" ) ;
0 commit comments