@@ -162,41 +162,43 @@ function getAffectedTestApplications(
162
162
// eslint-disable-next-line no-console
163
163
console . error ( `Nx affected projects (${ affectedProjects . length } ): ${ JSON . stringify ( affectedProjects ) } ` ) ;
164
164
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
166
174
if ( affectedProjects . includes ( '@sentry-internal/e2e-tests' ) ) {
167
175
try {
168
176
const changedTestApps = getChangedTestApps ( base , head ) ;
169
177
170
- // Shared code was changed, run all tests
171
178
if ( changedTestApps === false ) {
179
+ // Shared code was changed, run all tests
172
180
// eslint-disable-next-line no-console
173
181
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
180
185
// eslint-disable-next-line no-console
181
186
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 ) ) } ` ,
183
188
) ;
184
- return selected ;
189
+ testApplications . forEach ( testApp => {
190
+ if ( changedTestApps . has ( testApp ) ) {
191
+ testAppsToRun . add ( testApp ) ;
192
+ }
193
+ } ) ;
185
194
}
186
195
} catch ( error ) {
187
196
// 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 ) ;
190
198
}
191
-
192
- // Fall back to running all tests
193
- return testApplications ;
194
199
}
195
200
196
- return testApplications . filter ( testApp => {
197
- const sentryDependencies = getSentryDependencies ( testApp ) ;
198
- return sentryDependencies . some ( dep => affectedProjects . includes ( dep ) ) ;
199
- } ) ;
201
+ return Array . from ( testAppsToRun ) ;
200
202
}
201
203
202
204
function getChangedTestApps ( base : string , head ?: string ) : false | Set < string > {
0 commit comments