@@ -2,16 +2,17 @@ import { assert, test } from 'vitest'
22
33import { Sandbox } from '../../src/index.js'
44import { isDebug , template , wait } from '../setup.js'
5+ import { catchCmdExitErrorInBackground } from '../cmdHelper.js'
56
67test . skipIf ( isDebug ) ( 'closed port in SDK' , async ( ) => {
78 const sbx = await Sandbox . create ( template , { timeoutMs : 60_000 } )
89 const goodPort = 8000
910
10- await sbx . commands . run ( `python -m http.server ${ goodPort } ` , {
11+ const cmd = await sbx . commands . run ( `python -m http.server ${ goodPort } ` , {
1112 background : true ,
1213 } )
1314
14- await wait ( 1000 )
15+ const disable = catchCmdExitErrorInBackground ( cmd )
1516
1617 const goodHost = sbx . getHost ( goodPort )
1718 // leave this here as a helper to visit host in browser
@@ -44,16 +45,19 @@ test.skipIf(isDebug)('closed port in SDK', async () => {
4445 assert . equal ( resp . message , 'The sandbox is running but port is not open' )
4546 assert . equal ( cleanedSbxId , resp . sandboxId )
4647 assert . equal ( resp . port , badPort )
48+ disable ( )
4749} )
4850
4951test . skipIf ( isDebug ) ( 'closed port in browser ' , async ( ) => {
5052 const sbx = await Sandbox . create ( template , { timeoutMs : 60_000 } )
5153 const goodPort = 8000
5254
53- await sbx . commands . run ( `python -m http.server ${ goodPort } ` , {
55+ const cmd = await sbx . commands . run ( `python -m http.server ${ goodPort } ` , {
5456 background : true ,
5557 } )
5658
59+ const disable = catchCmdExitErrorInBackground ( cmd )
60+
5761 await wait ( 1000 )
5862
5963 const goodHost = sbx . getHost ( goodPort )
@@ -87,4 +91,5 @@ test.skipIf(isDebug)('closed port in browser ', async () => {
8791 assert . equal ( res . status , 502 )
8892 const resp_text = await res . text ( )
8993 assert ( resp_text . includes ( '<title>Closed Port Error</title>' ) )
94+ disable ( )
9095} )
0 commit comments