@@ -82,7 +82,12 @@ describe.skipIf(process.platform === "win32")("native multi-invocation report ow
8282 const index = json ( path . join ( result . reportSet ! , "index.json" ) ) ;
8383 expect ( index . complete ) . toBe ( true ) ;
8484 expect ( index . entries [ 1 ] . attempts [ 0 ] . outcome . code ) . toBe ( 1 ) ;
85- if ( mode === "unhandled" ) expect ( json ( index . entries [ 1 ] . attempts [ 0 ] . json ) . success ) . toBe ( true ) ;
85+ if ( mode === "unhandled" ) {
86+ const part = index . entries [ 1 ] . attempts [ 0 ] . json ;
87+ expect ( json ( part ) . success ) . toBe ( true ) ;
88+ expect ( json ( `${ part } .capture.json` ) . ended . unhandledErrors ) . toBe ( 1 ) ;
89+ expect ( result . stderr ) . toContain ( "owned unhandled rejection" ) ;
90+ }
8691 } ,
8792 ) ;
8893
@@ -108,12 +113,91 @@ describe.skipIf(process.platform === "win32")("native multi-invocation report ow
108113 const result = await run ( mode ) ;
109114 expect ( result . code !== 0 || result . signal !== null , result . stderr ) . toBe ( true ) ;
110115 const index = json ( path . join ( result . reportSet ! , "index.json" ) ) ;
116+ const first = index . entries [ 0 ] . attempts [ 0 ] ;
117+ const staged = path . join ( result . reportSet ! , "aggregate.json" ) ;
111118 if ( mode === "cancel" || mode === "batch-cancel" ) {
112119 expect ( result . signal ) . toBe ( "SIGTERM" ) ;
113- expect ( index . entries [ 0 ] . attempts [ 0 ] . outcome . signal ) . toBe ( "SIGTERM" ) ;
120+ expect ( first . outcome . signal ) . toBe ( "SIGTERM" ) ;
121+ const events = fs
122+ . readFileSync ( path . join ( path . dirname ( result . output ) , "executed.jsonl" ) , "utf8" )
123+ . trim ( )
124+ . split ( "\n" )
125+ . map ( ( line ) => JSON . parse ( line ) ) ;
126+ expect ( events . map ( ( event ) => event . name ) ) . toEqual ( [ "alpha/one" ] ) ;
127+ const capture = json ( `${ first . json } .capture.json` ) ;
128+ expect ( fs . readFileSync ( path . join ( capture . root , "ready" ) , "utf8" ) ) . toBe (
129+ String ( events [ 0 ] . pid ) ,
130+ ) ;
131+ expect ( ( ) => process . kill ( events [ 0 ] . pid , 0 ) ) . toThrow (
132+ expect . objectContaining ( { code : "ESRCH" } ) ,
133+ ) ;
134+ } else if ( mode === "fail-fast" || mode === "batch-fail-fast" ) {
135+ const report = json ( first . json ) ;
136+ expect ( inventory ( report ) ) . toEqual ( [
137+ [ "alpha/one" , "failed" ] ,
138+ [ "alpha/two" , "passed" ] ,
139+ ] ) ;
140+ expect ( report . testResults [ 0 ] . assertionResults [ 0 ] . failureMessages . join ( "\n" ) ) . toContain (
141+ "expected 1 to be 2" ,
142+ ) ;
143+ expect ( first . outcome . code ) . toBe ( 1 ) ;
144+ expect ( json ( `${ first . json } .capture.json` ) . ended . reason ) . toBe ( "failed" ) ;
145+ } else if ( mode === "tuple" ) {
146+ expect ( result . stderr ) . toContain ( "cannot preserve config-owned reporter options" ) ;
147+ } else {
148+ const capture = json ( `${ first . json } .capture.json` ) ;
149+ expect ( capture . ended . reason ) . toBe ( "passed" ) ;
150+ if ( mode === "child-write" ) {
151+ expect ( fs . statSync ( first . json ) . isDirectory ( ) ) . toBe ( true ) ;
152+ expect ( first . outcome . code ) . toBe ( 1 ) ;
153+ expect ( result . stderr ) . toContain ( "EISDIR" ) ;
154+ } else {
155+ const original = mode === "missing" ? `${ first . json } .native-original` : first . json ;
156+ expect ( inventory ( json ( original ) ) ) . toEqual ( expected . slice ( 0 , 2 ) ) ;
157+ expect ( first . outcome . code ) . toBe ( 0 ) ;
158+ }
159+ if ( mode === "missing" ) {
160+ expect ( fs . existsSync ( first . json ) ) . toBe ( false ) ;
161+ expect ( index . error ) . toContain ( "missing Vitest JSON report" ) ;
162+ } else if ( mode === "coverage-missing" ) {
163+ const lcov = path . join ( capture . coverageDirectory , "lcov.info" ) ;
164+ expect ( fs . readFileSync ( `${ lcov } .native-original` , "utf8" ) ) . toContain ( "covered.ts" ) ;
165+ expect ( fs . existsSync ( lcov ) ) . toBe ( false ) ;
166+ expect ( index . error ) . toContain ( lcov ) ;
167+ } else if ( mode === "teardown-timeout" ) {
168+ expect ( capture . processTimedOut ) . toBe ( true ) ;
169+ expect ( index . error ) . toContain ( "completion evidence missing or interrupted" ) ;
170+ } else if ( mode !== "child-write" ) {
171+ const second = index . entries [ 1 ] . attempts [ 0 ] ;
172+ expect ( inventory ( json ( second . json ) ) ) . toEqual ( expected . slice ( 2 ) ) ;
173+ expect ( second . outcome . code ) . toBe ( 0 ) ;
174+ expect ( index . merge . code ) . toBe ( mode === "publish-write" ? 0 : 1 ) ;
175+ if ( mode === "corrupt" ) {
176+ expect ( fs . readFileSync ( first . blob , "utf8" ) ) . toBe ( "owned corruption" ) ;
177+ expect ( ( ) => json ( `${ first . blob } .native-original` ) ) . not . toThrow ( ) ;
178+ expect ( result . stderr ) . toContain ( '"owned corruption" is not valid JSON' ) ;
179+ } else if ( mode === "merge-failure" ) {
180+ expect ( result . stderr ) . toContain ( "owned native merge failure" ) ;
181+ } else if ( mode === "identity" ) {
182+ expect ( result . stderr ) . toContain ( "Native merge project identity changed" ) ;
183+ } else if ( mode === "final-write" ) {
184+ expect ( fs . statSync ( staged ) . isDirectory ( ) ) . toBe ( true ) ;
185+ expect ( index . error ) . toContain ( "EISDIR" ) ;
186+ } else if ( mode === "publish-write" ) {
187+ expect ( inventory ( json ( staged ) ) ) . toEqual ( expected ) ;
188+ expect ( fs . readFileSync ( path . join ( result . output , "old" ) , "utf8" ) ) . toBe ( "old" ) ;
189+ expect ( fs . readFileSync ( path . join ( index . publication , "report.json" ) ) ) . toEqual (
190+ fs . readFileSync ( staged ) ,
191+ ) ;
192+ expect ( index . error ) . toMatch ( / r e n a m e / ) ;
193+ }
194+ }
114195 }
115196 expect ( index . complete ) . toBe ( false ) ;
116197 expect ( index . error ) . not . toBe ( "" ) ;
198+ expect ( index . aggregate ) . toBe ( "" ) ;
199+ if ( ! [ "corrupt" , "merge-failure" , "identity" , "final-write" , "publish-write" ] . includes ( mode ) )
200+ expect ( index . merge ) . toBeNull ( ) ;
117201 if ( [ "missing" , "corrupt" , "merge-failure" , "final-write" , "identity" ] . includes ( mode ) )
118202 expect ( fs . readFileSync ( result . output , "utf8" ) ) . toBe ( "old report" ) ;
119203 if ( [ "fail-fast" , "cancel" , "batch-fail-fast" , "batch-cancel" ] . includes ( mode ) )
0 commit comments