Stabilize E2E test by alphabetically sorting files for context (#321)

This commit is contained in:
Will Chen
2025-06-03 17:58:59 -07:00
committed by GitHub
parent c227a08d11
commit b8f7490288
5 changed files with 36 additions and 16 deletions

View File

@@ -370,6 +370,15 @@ async function sortFilesByModificationTime(files: string[]): Promise<string[]> {
}),
);
if (process.env.E2E_TEST_BUILD) {
// Why? For some reason, file ordering is not stable on Windows.
// This is a workaround to ensure stable ordering, although
// ideally we'd like to sort it by modification time which is
// important for cache-ability.
return fileStats
.sort((a, b) => a.file.localeCompare(b.file))
.map((item) => item.file);
}
// Sort by modification time (oldest first)
return fileStats.sort((a, b) => a.mtime - b.mtime).map((item) => item.file);
}