@@ -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,8 @@ 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+ this . modifiedFiles = hasImpactedTests ? modifiedFiles : this . testEnvironmentOptions . _ddModifiedFiles
204202 } catch ( e ) {
205203 log . error ( 'Error parsing impacted tests' , e )
206204 this . isImpactedTestsEnabled = false
@@ -290,19 +288,6 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
290288 return result
291289 }
292290
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-
306291 // Generic function to handle test retries
307292 retryTest ( {
308293 jestEvent,
@@ -378,7 +363,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
378363 this . testSourceFile ,
379364 testStartLine ,
380365 testEndLine ,
381- this . modifiedTestsForThisSuite ,
366+ this . modifiedFiles ,
382367 'jest'
383368 )
384369 }
@@ -465,7 +450,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
465450 this . testSourceFile ,
466451 testStartLine ,
467452 testEndLine ,
468- this . modifiedTestsForThisSuite ,
453+ this . modifiedFiles ,
469454 'jest'
470455 )
471456 if ( isModified && ! retriedTestsToNumAttempts . has ( testFullName ) && this . isEarlyFlakeDetectionEnabled ) {
@@ -831,12 +816,12 @@ function getCliWrapper (isNewJestVersion) {
831816 onDone = resolve
832817 } )
833818
834- impactedTestsCh . publish ( { onDone } )
819+ modifiedFilesCh . publish ( { onDone } )
835820
836821 try {
837- const { err, modifiedTests : receivedModifiedTests } = await impactedTestsPromise
822+ const { err, modifiedFiles : receivedModifiedFiles } = await impactedTestsPromise
838823 if ( ! err ) {
839- modifiedTests = receivedModifiedTests
824+ modifiedFiles = receivedModifiedFiles
840825 }
841826 } catch ( err ) {
842827 log . error ( 'Jest impacted tests error' , err )
@@ -1237,7 +1222,7 @@ addHook({
12371222 _ddIsTestManagementTestsEnabled,
12381223 _ddTestManagementTests,
12391224 _ddTestManagementAttemptToFixRetries,
1240- _ddModifiedTests ,
1225+ _ddModifiedFiles ,
12411226 ...restOfTestEnvironmentOptions
12421227 } = testEnvironmentOptions
12431228
@@ -1365,17 +1350,15 @@ function sendWrapper (send) {
13651350
13661351 const suiteTestManagementTests = testManagementTests ?. jest ?. suites ?. [ testSuite ] ?. tests || { }
13671352
1368- const suiteModifiedTests = Object . keys ( modifiedTests ) . length > 0
1369- ? modifiedTests
1370- : { }
1371-
13721353 args [ 0 ] . config = {
13731354 ...config ,
13741355 testEnvironmentOptions : {
13751356 ...config . testEnvironmentOptions ,
13761357 _ddKnownTests : suiteKnownTests ,
13771358 _ddTestManagementTests : suiteTestManagementTests ,
1378- _ddModifiedTests : suiteModifiedTests
1359+ // TODO: figure out if we can reduce the size of the modified files object
1360+ // Can we use `testSuite` (it'd have to be relative to repository root though)
1361+ _ddModifiedFiles : modifiedFiles
13791362 }
13801363 }
13811364 }
0 commit comments