@@ -162,41 +162,43 @@ function getAffectedTestApplications(
162162 // eslint-disable-next-line no-console
163163 console . error ( `Nx affected projects (${ affectedProjects . length } ): ${ JSON . stringify ( affectedProjects ) } ` ) ;
164164
165- // If something in e2e tests themselves are changed, check if only test applications were changed
165+ // Run all test apps that have affected projects as dependencies
166+ const testAppsToRun = new Set (
167+ testApplications . filter ( testApp => {
168+ const sentryDependencies = getSentryDependencies ( testApp ) ;
169+ return sentryDependencies . some ( dep => affectedProjects . includes ( dep ) ) ;
170+ } ) ,
171+ ) ;
172+
173+ // If something in e2e tests themselves are changed, add changed test applications as well
166174 if ( affectedProjects . includes ( '@sentry-internal/e2e-tests' ) ) {
167175 try {
168176 const changedTestApps = getChangedTestApps ( base , head ) ;
169177
170- // Shared code was changed, run all tests
171178 if ( changedTestApps === false ) {
179+ // Shared code was changed, run all tests
172180 // eslint-disable-next-line no-console
173181 console . error ( 'Shared e2e code changed. Running all test applications.' ) ;
174- return testApplications ;
175- }
176-
177- // Only test applications that were changed, run selectively
178- if ( changedTestApps . size > 0 ) {
179- const selected = testApplications . filter ( testApp => changedTestApps . has ( testApp ) ) ;
182+ testApplications . forEach ( testApp => testAppsToRun . add ( testApp ) ) ;
183+ } else if ( changedTestApps . size > 0 ) {
184+ // Only test applications that were changed, run selectively
180185 // eslint-disable-next-line no-console
181186 console . error (
182- `Only changed test applications will run (${ selected . length } ): ${ JSON . stringify ( Array . from ( changedTestApps ) ) } ` ,
187+ `Only changed test applications will run (${ changedTestApps . size } ): ${ JSON . stringify ( Array . from ( changedTestApps ) ) } ` ,
183188 ) ;
184- return selected ;
189+ testApplications . forEach ( testApp => {
190+ if ( changedTestApps . has ( testApp ) ) {
191+ testAppsToRun . add ( testApp ) ;
192+ }
193+ } ) ;
185194 }
186195 } catch ( error ) {
187196 // eslint-disable-next-line no-console
188- console . error ( 'Failed to get changed files, running all tests:' , error ) ;
189- return testApplications ;
197+ console . error ( 'Failed to get changed files:' , error ) ;
190198 }
191-
192- // Fall back to running all tests
193- return testApplications ;
194199 }
195200
196- return testApplications . filter ( testApp => {
197- const sentryDependencies = getSentryDependencies ( testApp ) ;
198- return sentryDependencies . some ( dep => affectedProjects . includes ( dep ) ) ;
199- } ) ;
201+ return Array . from ( testAppsToRun ) ;
200202}
201203
202204function getChangedTestApps ( base : string , head ?: string ) : false | Set < string > {
0 commit comments