Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions dev-packages/e2e-tests/lib/getTestMatrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,41 +162,43 @@ function getAffectedTestApplications(
// eslint-disable-next-line no-console
console.error(`Nx affected projects (${affectedProjects.length}): ${JSON.stringify(affectedProjects)}`);

// If something in e2e tests themselves are changed, check if only test applications were changed
// Run all test apps that have affected projects as dependencies
const testAppsToRun = new Set(
testApplications.filter(testApp => {
const sentryDependencies = getSentryDependencies(testApp);
return sentryDependencies.some(dep => affectedProjects.includes(dep));
}),
);

// If something in e2e tests themselves are changed, add changed test applications as well
if (affectedProjects.includes('@sentry-internal/e2e-tests')) {
try {
const changedTestApps = getChangedTestApps(base, head);

// Shared code was changed, run all tests
if (changedTestApps === false) {
// Shared code was changed, run all tests
// eslint-disable-next-line no-console
console.error('Shared e2e code changed. Running all test applications.');
return testApplications;
}

// Only test applications that were changed, run selectively
if (changedTestApps.size > 0) {
const selected = testApplications.filter(testApp => changedTestApps.has(testApp));
testApplications.forEach(testApp => testAppsToRun.add(testApp));
} else if (changedTestApps.size > 0) {
// Only test applications that were changed, run selectively
// eslint-disable-next-line no-console
console.error(
`Only changed test applications will run (${selected.length}): ${JSON.stringify(Array.from(changedTestApps))}`,
`Only changed test applications will run (${changedTestApps.size}): ${JSON.stringify(Array.from(changedTestApps))}`,
);
return selected;
testApplications.forEach(testApp => {
if (changedTestApps.has(testApp)) {
testAppsToRun.add(testApp);
}
});
}
} catch (error) {
// eslint-disable-next-line no-console
console.error('Failed to get changed files, running all tests:', error);
return testApplications;
console.error('Failed to get changed files:', error);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Error Handling Loses Fallback for Test Coverage

The error handling for getChangedTestApps no longer includes a safe fallback. If getting changed files fails, the original code would run all tests. Now, it only logs the error and continues, which could lead to insufficient test coverage or no tests running when e2e tests are affected.

Fix in Cursor Fix in Web

}

// Fall back to running all tests
return testApplications;
}

return testApplications.filter(testApp => {
const sentryDependencies = getSentryDependencies(testApp);
return sentryDependencies.some(dep => affectedProjects.includes(dep));
});
return Array.from(testAppsToRun);
}

function getChangedTestApps(base: string, head?: string): false | Set<string> {
Expand Down