@@ -47,6 +47,12 @@ describe('GitDataSource', () => {
4747 const onGitInfoChange = sinon . stub ( )
4848 const onError = sinon . stub ( )
4949
50+ // create a file and modify a file to express all
51+ // git states we are interested in (created, unmodified, modified)
52+ const fooSpec = path . join ( e2eFolder , 'foo.cy.js' )
53+ const aRecordSpec = path . join ( e2eFolder , 'a_record.cy.js' )
54+ const xhrSpec = path . join ( e2eFolder , 'xhr.cy.js' )
55+
5056 gitInfo = new GitDataSource ( {
5157 isRunMode : false ,
5258 projectRoot : projectPath ,
@@ -55,28 +61,24 @@ describe('GitDataSource', () => {
5561 onError,
5662 } )
5763
58- // create a file and modify a file to express all
59- // git states we are interested in (created, unmodified, modified)
60- const fooSpec = path . join ( e2eFolder , 'foo.cy.js' )
61- const aRecordSpec = path . join ( e2eFolder , 'a_record.cy.js' )
62- const xhrSpec = path . join ( e2eFolder , 'xhr.cy.js' )
63-
6464 fs . createFileSync ( fooSpec )
6565 fs . writeFileSync ( xhrSpec , 'it(\'modifies the file\', () => {})' )
6666
67- const dfd = pDefer ( )
67+ gitInfo . setSpecs ( [ fooSpec , aRecordSpec , xhrSpec ] )
6868
69- onGitInfoChange . onSecondCall ( ) . callsFake ( dfd . resolve )
69+ let result : any [ ] = [ ]
7070
71- gitInfo . setSpecs ( [ fooSpec , aRecordSpec , xhrSpec ] )
71+ do {
72+ result = await Promise . all ( [
73+ gitInfo . gitInfoFor ( fooSpec ) ,
74+ gitInfo . gitInfoFor ( aRecordSpec ) ,
75+ gitInfo . gitInfoFor ( xhrSpec ) ,
76+ ] )
7277
73- await dfd . promise
78+ await new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) )
79+ } while ( result . some ( ( r ) => r == null ) )
7480
75- const [ created , unmodified , modified ] = await Promise . all ( [
76- gitInfo . gitInfoFor ( fooSpec ) ,
77- gitInfo . gitInfoFor ( aRecordSpec ) ,
78- gitInfo . gitInfoFor ( xhrSpec ) ,
79- ] )
81+ const [ created , unmodified , modified ] = result
8082
8183 expect ( created . lastModifiedHumanReadable ) . to . match ( / ( a f e w | [ 0 - 9 ] ) s e c o n d s ? a g o / )
8284 expect ( created . statusType ) . to . eql ( 'created' )
0 commit comments