@@ -4,7 +4,11 @@ import { tmpdir } from 'node:os'
44import { join , resolve } from 'node:path'
55import { expect , it } from 'vitest'
66
7- it ( 'executes imported test factories and unmeasured files exactly once across desktop shards' , ( ) => {
7+ it . each ( [
8+ { index : 1 , title : 'brand-new.test.ts' } ,
9+ { index : 2 , title : 'factory' } ,
10+ { index : 3 , title : 'ordinary.spec.ts' } ,
11+ ] ) ( 'executes only $title on desktop shard $index/3' , ( { index, title } ) => {
812 const root = resolve ( import . meta. dirname , '..' )
913 const fixture = mkdtempSync ( join ( tmpdir ( ) , 'desktop-shard-' ) )
1014 try {
@@ -31,34 +35,25 @@ it('executes imported test factories and unmeasured files exactly once across de
3135 )
3236 }
3337 const cases : { title : string ; status : string } [ ] = [ ]
34- for ( const index of [ 1 , 2 , 3 ] ) {
35- const reportPath = join ( fixture , `${ index } .json` )
36- const result = spawnSync ( 'bun' , [ 'run' , join ( root , 'scripts/desktop-e2e.ts' ) , `${ index } /3` ] , {
37- cwd : fixture ,
38- env : { ...process . env , PLAYWRIGHT_JSON_OUTPUT_FILE : reportPath } ,
39- encoding : 'utf8' ,
40- timeout : 10_000 ,
41- } )
42- expect ( result . status , result . stdout + result . stderr ) . toBe ( 0 )
43- const report = JSON . parse ( readFileSync ( reportPath , 'utf8' ) ) as {
44- suites : { specs : { title : string ; tests : { results : { status : string } [ ] } [ ] } [ ] } [ ]
45- }
46- for ( const suite of report . suites ) {
47- for ( const spec of suite . specs ) {
48- for ( const test of spec . tests ) {
49- for ( const run of test . results ) cases . push ( { title : spec . title , status : run . status } )
50- }
38+ const reportPath = join ( fixture , `${ index } .json` )
39+ const result = spawnSync ( 'bun' , [ 'run' , join ( root , 'scripts/desktop-e2e.ts' ) , `${ index } /3` ] , {
40+ cwd : fixture ,
41+ env : { ...process . env , PLAYWRIGHT_JSON_OUTPUT_FILE : reportPath } ,
42+ encoding : 'utf8' ,
43+ timeout : 10_000 ,
44+ } )
45+ expect ( result . status , result . stdout + result . stderr ) . toBe ( 0 )
46+ const report = JSON . parse ( readFileSync ( reportPath , 'utf8' ) ) as {
47+ suites : { specs : { title : string ; tests : { results : { status : string } [ ] } [ ] } [ ] } [ ]
48+ }
49+ for ( const suite of report . suites ) {
50+ for ( const spec of suite . specs ) {
51+ for ( const test of spec . tests ) {
52+ for ( const run of test . results ) cases . push ( { title : spec . title , status : run . status } )
5153 }
5254 }
5355 }
54- expect ( cases ) . toEqual (
55- expect . arrayContaining ( [
56- { title : 'factory' , status : 'passed' } ,
57- { title : 'brand-new.test.ts' , status : 'passed' } ,
58- { title : 'ordinary.spec.ts' , status : 'passed' } ,
59- ] )
60- )
61- expect ( cases ) . toHaveLength ( 3 )
56+ expect ( cases ) . toEqual ( [ { title, status : 'passed' } ] )
6257 } finally {
6358 rmSync ( fixture , { recursive : true , force : true } )
6459 }
0 commit comments