@@ -111,6 +111,12 @@ function fixture(name) {
111111 return { root, source, artifact } ;
112112}
113113
114+ function parseProbeResult ( stdout ) {
115+ const match = stdout . match ( / ^ _ _ D A T A O P S _ P A C K A G E D _ H A N D L E R _ P R O B E _ _ ( .* ) $ / m) ;
116+ assert . ok ( match , 'Packaged handler probe omitted its marked result record' ) ;
117+ return JSON . parse ( match [ 1 ] ) ;
118+ }
119+
114120function run ( source , artifact , extra = [ ] ) {
115121 return spawnSync ( process . execPath , [ verifier , '--source' , source , '--artifact' , artifact , ...extra ] , { encoding : 'utf8' } ) ;
116122}
@@ -330,7 +336,7 @@ describe('isolated SAM handler frontend runtime', () => {
330336 const manifestAssets = readFrontendAssetManifest ( ) . files . map ( ( asset ) => `/${ asset } ` ) ;
331337 const positive = await probe ( isolated , [ '/' , '/workspace/deep-link' , ...manifestAssets , '/src/../package.json' , '/src/missing.js' , '/public/app.js' , '/public/extensionless' , '/unknown.js' , '/api/not-a-route' , '/work/api' ] , 'Packaged frontend positive-route probe' ) ;
332338 assert . equal ( positive . status , 0 , positive . stderr ) ;
333- const result = JSON . parse ( positive . stdout ) ;
339+ const result = parseProbeResult ( positive . stdout ) ;
334340 assert . equal ( result . outsideModuleResolution , false , JSON . stringify ( result . outsideModuleResolutions ) ) ;
335341 const responses = new Map ( result . responses . map ( ( response ) => [ response . path , response ] ) ) ;
336342 const responseFor = ( path ) => {
@@ -375,7 +381,7 @@ describe('isolated SAM handler frontend runtime', () => {
375381 renameSync ( join ( missing , 'dist/frontend/index.html' ) , join ( missing , 'dist/frontend/index.missing' ) ) ;
376382 const missingResult = await probe ( missing , [ '/' ] , 'Packaged frontend missing-index probe' ) ;
377383 assert . equal ( missingResult . status , 0 , missingResult . stderr ) ;
378- const missingResponse = JSON . parse ( missingResult . stdout ) . responses [ 0 ] ;
384+ const missingResponse = parseProbeResult ( missingResult . stdout ) . responses [ 0 ] ;
379385 assert . ok ( missingResponse , '/ (missing index fixture): packaged handler returned no response' ) ;
380386 assert . equal ( missingResponse . statusCode , 500 , '/ (missing index fixture): missing frontend must return 500' ) ;
381387 assert . match ( missingResponse . contentType , / a p p l i c a t i o n \/ j s o n / , '/ (missing index fixture): error must be JSON' ) ;
0 commit comments