@@ -46,7 +46,7 @@ const skippableSuitesCh = channel('ci:jest:test-suite:skippable')
4646const  libraryConfigurationCh  =  channel ( 'ci:jest:library-configuration' ) 
4747const  knownTestsCh  =  channel ( 'ci:jest:known-tests' ) 
4848const  testManagementTestsCh  =  channel ( 'ci:jest:test-management-tests' ) 
49- const  impactedTestsCh  =  channel ( 'ci:jest:modified-tests ' ) 
49+ const  modifiedFilesCh  =  channel ( 'ci:jest:modified-files ' ) 
5050
5151const  itrSkippedSuitesCh  =  channel ( 'ci:jest:itr:skipped-suites' ) 
5252
@@ -78,7 +78,7 @@ let isTestManagementTestsEnabled = false
7878let  testManagementTests  =  { } 
7979let  testManagementAttemptToFixRetries  =  0 
8080let  isImpactedTestsEnabled  =  false 
81- let  modifiedTests  =  { } 
81+ let  modifiedFiles  =  { } 
8282
8383const  testContexts  =  new  WeakMap ( ) 
8484const  originalTestFns  =  new  WeakMap ( ) 
@@ -197,10 +197,9 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
197197
198198      if  ( this . isImpactedTestsEnabled )  { 
199199        try  { 
200-           const  hasImpactedTests  =  Object . keys ( modifiedTests ) . length  >  0 
201-           this . modifiedTestsForThisSuite  =  hasImpactedTests 
202-             ? this . getModifiedTestForThisSuite ( modifiedTests ) 
203-             : this . getModifiedTestForThisSuite ( this . testEnvironmentOptions . _ddModifiedTests ) 
200+           const  hasImpactedTests  =  Object . keys ( modifiedFiles ) . length  >  0 
201+           // TODO: check if `this.testEnvironmentOptions._ddModifiedFiles` is serialized to JSON 
202+           this . modifiedFiles  =  hasImpactedTests  ? modifiedFiles  : this . testEnvironmentOptions . _ddModifiedFiles 
204203        }  catch  ( e )  { 
205204          log . error ( 'Error parsing impacted tests' ,  e ) 
206205          this . isImpactedTestsEnabled  =  false 
@@ -290,19 +289,6 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
290289      return  result 
291290    } 
292291
293-     getModifiedTestForThisSuite  ( modifiedTests )  { 
294-       if  ( this . modifiedTestsForThisSuite )  { 
295-         return  this . modifiedTestsForThisSuite 
296-       } 
297-       let  modifiedTestsForThisSuite  =  modifiedTests 
298-       // If jest is using workers, modified tests are serialized to json. 
299-       // If jest runs in band, they are not. 
300-       if  ( typeof  modifiedTestsForThisSuite  ===  'string' )  { 
301-         modifiedTestsForThisSuite  =  JSON . parse ( modifiedTestsForThisSuite ) 
302-       } 
303-       return  modifiedTestsForThisSuite 
304-     } 
305- 
306292    // Generic function to handle test retries 
307293    retryTest  ( { 
308294      jestEvent, 
@@ -378,7 +364,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
378364            this . testSourceFile , 
379365            testStartLine , 
380366            testEndLine , 
381-             this . modifiedTestsForThisSuite , 
367+             this . modifiedFiles , 
382368            'jest' 
383369          ) 
384370        } 
@@ -465,7 +451,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
465451            this . testSourceFile , 
466452            testStartLine , 
467453            testEndLine , 
468-             this . modifiedTestsForThisSuite , 
454+             this . modifiedFiles , 
469455            'jest' 
470456          ) 
471457          if  ( isModified  &&  ! retriedTestsToNumAttempts . has ( testFullName )  &&  this . isEarlyFlakeDetectionEnabled )  { 
@@ -831,12 +817,12 @@ function getCliWrapper (isNewJestVersion) {
831817          onDone  =  resolve 
832818        } ) 
833819
834-         impactedTestsCh . publish ( {  onDone } ) 
820+         modifiedFilesCh . publish ( {  onDone } ) 
835821
836822        try  { 
837-           const  {  err,  modifiedTests :  receivedModifiedTests  }  =  await  impactedTestsPromise 
823+           const  {  err,  modifiedFiles :  receivedModifiedFiles  }  =  await  impactedTestsPromise 
838824          if  ( ! err )  { 
839-             modifiedTests  =  receivedModifiedTests 
825+             modifiedFiles  =  receivedModifiedFiles 
840826          } 
841827        }  catch  ( err )  { 
842828          log . error ( 'Jest impacted tests error' ,  err ) 
@@ -1237,7 +1223,7 @@ addHook({
12371223      _ddIsTestManagementTestsEnabled, 
12381224      _ddTestManagementTests, 
12391225      _ddTestManagementAttemptToFixRetries, 
1240-       _ddModifiedTests , 
1226+       _ddModifiedFiles , 
12411227      ...restOfTestEnvironmentOptions 
12421228    }  =  testEnvironmentOptions 
12431229
@@ -1365,17 +1351,15 @@ function sendWrapper (send) {
13651351
13661352      const  suiteTestManagementTests  =  testManagementTests ?. jest ?. suites ?. [ testSuite ] ?. tests  ||  { } 
13671353
1368-       const  suiteModifiedTests  =  Object . keys ( modifiedTests ) . length  >  0 
1369-         ? modifiedTests 
1370-         : { } 
1371- 
13721354      args [ 0 ] . config  =  { 
13731355        ...config , 
13741356        testEnvironmentOptions : { 
13751357          ...config . testEnvironmentOptions , 
13761358          _ddKnownTests : suiteKnownTests , 
13771359          _ddTestManagementTests : suiteTestManagementTests , 
1378-           _ddModifiedTests : suiteModifiedTests 
1360+           // TODO: figure out if we can reduce the size of the modified files object 
1361+           // Can we use `testSuite` (it'd have to be relative to repository root though) 
1362+           _ddModifiedFiles : modifiedFiles 
13791363        } 
13801364      } 
13811365    } 
0 commit comments