Running as unit: run-p3124894-i28303798.scope; invocation ID: 81773b4a1f514bbc9d9bd455799ee95c bun test v1.4.4 (38afee6c8) student-tests/browser-lifecycle.test.ts: 3 | const primary=Object.hasOwn(flags,'primary')?flags.primary:new Error(flags.setup??'WORK'),reportError=new Error('RESULT_WRITE'),closeError=new Error('CLOSE'),resource={id:'synthetic-browser'},events:string[]=[],secondary:{kind:string;error:unknown}[]=[];let closes=0,acquires=0; 4 | const run=createBrowserLifecycle({acquire:async()=>{acquires++;if(flags.acquire)throw primary;return resource},run:async received=>{expect(received).toBe(resource);events.push('run');if(flags.setup||Object.hasOwn(flags,'primary'))throw primary;return 17},close:async received=>{expect(received).toBe(resource);closes++;events.push('close');if(flags.close)throw closeError},reportResult:async(result,failure)=>{events.push('report');if(flags.report)throw reportError;if(flags.setup||Object.hasOwn(flags,'primary'))expect(failure?.error).toBe(primary);else expect(result).toBe(17)},reportSecondaryFailure:async(kind,error)=>{secondary.push({kind,error});if(flags.secondaryReport)throw Error('SECONDARY_REPORT')}}); 5 | return{run,primary,reportError,closeError,events,secondary,closes:()=>closes,acquires:()=>acquires}; 6 | } 7 | async function captured(run:()=>Promise){try{return{threw:false,value:await run(),error:undefined}}catch(error){return{threw:true,value:undefined,error}}} 8 | test('context setup rejection closes the acquired owned browser',async()=>{const f=fixture({setup:'newContext'}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.primary)}); ^ error: expect(received).toBe(expected) Expected: 1 Received: 0 at (/mnt/data/home/bench-saves/mtuci-vp-remaining-20261115/lab6/student-tests/browser-lifecycle.test.ts:8:162) (fail) context setup rejection closes the acquired owned browser [0.50ms] 4 | const run=createBrowserLifecycle({acquire:async()=>{acquires++;if(flags.acquire)throw primary;return resource},run:async received=>{expect(received).toBe(resource);events.push('run');if(flags.setup||Object.hasOwn(flags,'primary'))throw primary;return 17},close:async received=>{expect(received).toBe(resource);closes++;events.push('close');if(flags.close)throw closeError},reportResult:async(result,failure)=>{events.push('report');if(flags.report)throw reportError;if(flags.setup||Object.hasOwn(flags,'primary'))expect(failure?.error).toBe(primary);else expect(result).toBe(17)},reportSecondaryFailure:async(kind,error)=>{secondary.push({kind,error});if(flags.secondaryReport)throw Error('SECONDARY_REPORT')}}); 5 | return{run,primary,reportError,closeError,events,secondary,closes:()=>closes,acquires:()=>acquires}; 6 | } 7 | async function captured(run:()=>Promise){try{return{threw:false,value:await run(),error:undefined}}catch(error){return{threw:true,value:undefined,error}}} 8 | test('context setup rejection closes the acquired owned browser',async()=>{const f=fixture({setup:'newContext'}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.primary)}); 9 | test('page setup rejection closes the acquired owned browser',async()=>{const f=fixture({setup:'newPage'}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.primary)}); ^ error: expect(received).toBe(expected) Expected: 1 Received: 0 at (/mnt/data/home/bench-saves/mtuci-vp-remaining-20261115/lab6/student-tests/browser-lifecycle.test.ts:9:156) (fail) page setup rejection closes the acquired owned browser [0.08ms] 5 | return{run,primary,reportError,closeError,events,secondary,closes:()=>closes,acquires:()=>acquires}; 6 | } 7 | async function captured(run:()=>Promise){try{return{threw:false,value:await run(),error:undefined}}catch(error){return{threw:true,value:undefined,error}}} 8 | test('context setup rejection closes the acquired owned browser',async()=>{const f=fixture({setup:'newContext'}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.primary)}); 9 | test('page setup rejection closes the acquired owned browser',async()=>{const f=fixture({setup:'newPage'}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.primary)}); 10 | test('result-write rejection still closes and remains the primary failure',async()=>{const f=fixture({report:true}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.reportError)}); ^ error: expect(received).toBe(expected) Expected: 1 Received: 0 at (/mnt/data/home/bench-saves/mtuci-vp-remaining-20261115/lab6/student-tests/browser-lifecycle.test.ts:10:165) (fail) result-write rejection still closes and remains the primary failure [0.17ms] 6 | } 7 | async function captured(run:()=>Promise){try{return{threw:false,value:await run(),error:undefined}}catch(error){return{threw:true,value:undefined,error}}} 8 | test('context setup rejection closes the acquired owned browser',async()=>{const f=fixture({setup:'newContext'}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.primary)}); 9 | test('page setup rejection closes the acquired owned browser',async()=>{const f=fixture({setup:'newPage'}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.primary)}); 10 | test('result-write rejection still closes and remains the primary failure',async()=>{const f=fixture({report:true}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.reportError)}); 11 | test('work failure survives simultaneous result-write failure',async()=>{const primary=new Error('ORIGINAL'),f=fixture({primary,report:true}),result=await captured(f.run);expect(result.error).toBe(primary);expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'report',error:f.reportError}])}); ^ error: expect(received).toBe(expected) Expected: 1 Received: 0 at (/mnt/data/home/bench-saves/mtuci-vp-remaining-20261115/lab6/student-tests/browser-lifecycle.test.ts:11:226) (fail) work failure survives simultaneous result-write failure [0.12ms] 7 | async function captured(run:()=>Promise){try{return{threw:false,value:await run(),error:undefined}}catch(error){return{threw:true,value:undefined,error}}} 8 | test('context setup rejection closes the acquired owned browser',async()=>{const f=fixture({setup:'newContext'}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.primary)}); 9 | test('page setup rejection closes the acquired owned browser',async()=>{const f=fixture({setup:'newPage'}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.primary)}); 10 | test('result-write rejection still closes and remains the primary failure',async()=>{const f=fixture({report:true}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.reportError)}); 11 | test('work failure survives simultaneous result-write failure',async()=>{const primary=new Error('ORIGINAL'),f=fixture({primary,report:true}),result=await captured(f.run);expect(result.error).toBe(primary);expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'report',error:f.reportError}])}); 12 | test('primary failure survives close and secondary-reporter failures',async()=>{const primary=new Error('ORIGINAL'),f=fixture({primary,close:true,secondaryReport:true}),result=await captured(f.run);expect(result.error).toBe(primary);expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'close',error:f.closeError}])}); ^ error: expect(received).toBe(expected) Expected: 1 Received: 0 at (/mnt/data/home/bench-saves/mtuci-vp-remaining-20261115/lab6/student-tests/browser-lifecycle.test.ts:12:253) (fail) primary failure survives close and secondary-reporter failures [0.10ms] 8 | test('context setup rejection closes the acquired owned browser',async()=>{const f=fixture({setup:'newContext'}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.primary)}); 9 | test('page setup rejection closes the acquired owned browser',async()=>{const f=fixture({setup:'newPage'}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.primary)}); 10 | test('result-write rejection still closes and remains the primary failure',async()=>{const f=fixture({report:true}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.reportError)}); 11 | test('work failure survives simultaneous result-write failure',async()=>{const primary=new Error('ORIGINAL'),f=fixture({primary,report:true}),result=await captured(f.run);expect(result.error).toBe(primary);expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'report',error:f.reportError}])}); 12 | test('primary failure survives close and secondary-reporter failures',async()=>{const primary=new Error('ORIGINAL'),f=fixture({primary,close:true,secondaryReport:true}),result=await captured(f.run);expect(result.error).toBe(primary);expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'close',error:f.closeError}])}); 13 | test('close failure after success remains a separately reported failure',async()=>{const f=fixture({close:true}),result=await captured(f.run);expect(result.error).toBe(f.closeError);expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'close',error:f.closeError}])}); ^ error: expect(received).toEqual(expected) - [ - { - "error": [Error: CLOSE], - "kind": "close", - }, - ] + [] - Expected - 6 + Received + 1 at (/mnt/data/home/bench-saves/mtuci-vp-remaining-20261115/lab6/student-tests/browser-lifecycle.test.ts:13:230) (fail) close failure after success remains a separately reported failure [0.20ms] (pass) acquisition failure does not close a nonexistent browser [0.05ms] 10 | test('result-write rejection still closes and remains the primary failure',async()=>{const f=fixture({report:true}),result=await captured(f.run);expect(f.closes()).toBe(1);expect(result.error).toBe(f.reportError)}); 11 | test('work failure survives simultaneous result-write failure',async()=>{const primary=new Error('ORIGINAL'),f=fixture({primary,report:true}),result=await captured(f.run);expect(result.error).toBe(primary);expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'report',error:f.reportError}])}); 12 | test('primary failure survives close and secondary-reporter failures',async()=>{const primary=new Error('ORIGINAL'),f=fixture({primary,close:true,secondaryReport:true}),result=await captured(f.run);expect(result.error).toBe(primary);expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'close',error:f.closeError}])}); 13 | test('close failure after success remains a separately reported failure',async()=>{const f=fixture({close:true}),result=await captured(f.run);expect(result.error).toBe(f.closeError);expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'close',error:f.closeError}])}); 14 | test('acquisition failure does not close a nonexistent browser',async()=>{const f=fixture({acquire:true}),result=await captured(f.run);expect(result.error).toBe(f.primary);expect(f.closes()).toBe(0)}); 15 | test('missing required ports fail before acquisition',()=>{expect(()=>createBrowserLifecycle({}as any)).toThrow('BROWSER_LIFECYCLE_PORTS_REQUIRED')}); ^ error: expect(received).toThrow(expected) Expected substring: "BROWSER_LIFECYCLE_PORTS_REQUIRED" Received function did not throw Received value: [AsyncFunction] at (/mnt/data/home/bench-saves/mtuci-vp-remaining-20261115/lab6/student-tests/browser-lifecycle.test.ts:15:105) (fail) missing required ports fail before acquisition [0.06ms] 11 | test('work failure survives simultaneous result-write failure',async()=>{const primary=new Error('ORIGINAL'),f=fixture({primary,report:true}),result=await captured(f.run);expect(result.error).toBe(primary);expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'report',error:f.reportError}])}); 12 | test('primary failure survives close and secondary-reporter failures',async()=>{const primary=new Error('ORIGINAL'),f=fixture({primary,close:true,secondaryReport:true}),result=await captured(f.run);expect(result.error).toBe(primary);expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'close',error:f.closeError}])}); 13 | test('close failure after success remains a separately reported failure',async()=>{const f=fixture({close:true}),result=await captured(f.run);expect(result.error).toBe(f.closeError);expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'close',error:f.closeError}])}); 14 | test('acquisition failure does not close a nonexistent browser',async()=>{const f=fixture({acquire:true}),result=await captured(f.run);expect(result.error).toBe(f.primary);expect(f.closes()).toBe(0)}); 15 | test('missing required ports fail before acquisition',()=>{expect(()=>createBrowserLifecycle({}as any)).toThrow('BROWSER_LIFECYCLE_PORTS_REQUIRED')}); 16 | test('thrown undefined is preserved when cleanup also fails',async()=>{const f=fixture({primary:undefined,close:true}),result=await captured(f.run);expect(result.threw).toBe(true);expect(result.error).toBeUndefined();expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'close',error:f.closeError}])}); ^ error: expect(received).toBe(expected) Expected: 1 Received: 0 at (/mnt/data/home/bench-saves/mtuci-vp-remaining-20261115/lab6/student-tests/browser-lifecycle.test.ts:16:237) (fail) thrown undefined is preserved when cleanup also fails [0.08ms] 12 | test('primary failure survives close and secondary-reporter failures',async()=>{const primary=new Error('ORIGINAL'),f=fixture({primary,close:true,secondaryReport:true}),result=await captured(f.run);expect(result.error).toBe(primary);expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'close',error:f.closeError}])}); 13 | test('close failure after success remains a separately reported failure',async()=>{const f=fixture({close:true}),result=await captured(f.run);expect(result.error).toBe(f.closeError);expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'close',error:f.closeError}])}); 14 | test('acquisition failure does not close a nonexistent browser',async()=>{const f=fixture({acquire:true}),result=await captured(f.run);expect(result.error).toBe(f.primary);expect(f.closes()).toBe(0)}); 15 | test('missing required ports fail before acquisition',()=>{expect(()=>createBrowserLifecycle({}as any)).toThrow('BROWSER_LIFECYCLE_PORTS_REQUIRED')}); 16 | test('thrown undefined is preserved when cleanup also fails',async()=>{const f=fixture({primary:undefined,close:true}),result=await captured(f.run);expect(result.threw).toBe(true);expect(result.error).toBeUndefined();expect(f.closes()).toBe(1);expect(f.secondary).toEqual([{kind:'close',error:f.closeError}])}); 17 | test('successful work closes before reporting and returns its value',async()=>{const f=fixture();expect(await f.run()).toBe(17);expect(f.closes()).toBe(1);expect(f.events).toEqual(['run','close','report']);expect(f.secondary).toEqual([])}); ^ error: expect(received).toEqual(expected) [ "run", - "close", "report", + "close", ] - Expected - 1 + Received + 1 at (/mnt/data/home/bench-saves/mtuci-vp-remaining-20261115/lab6/student-tests/browser-lifecycle.test.ts:17:173) (fail) successful work closes before reporting and returns its value [0.10ms] 1 pass 9 fail 31 expect() calls Ran 10 tests across 1 file. [4.00ms]