Skip to content

Commit 04ec7af

Browse files
committed
test(backup): use Promise.allSettled for file operations
Convert Promise.all to Promise.allSettled in patch backup tests to ensure all file creation and backup operations complete even if one fails. This prevents test pollution and provides better diagnostics.
1 parent a095db7 commit 04ec7af

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

packages/cli/src/utils/manifest/patch-backup.test.mts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,13 @@ describe('patch-backup', () => {
440440
)
441441

442442
// Create files
443-
await Promise.all(files.map((file, i) => writeFile(file, `content ${i}`)))
443+
await Promise.allSettled(files.map((file, i) => writeFile(file, `content ${i}`)))
444444

445445
// Create backups concurrently
446-
const results = await Promise.all(
446+
const settled = await Promise.allSettled(
447447
files.map(file => createBackup(uuid, file)),
448448
)
449+
const results = settled.filter(r => r.status === 'fulfilled').map(r => r.value)
449450

450451
// Verify all backups were created
451452
expect(results).toHaveLength(5)
@@ -471,7 +472,7 @@ describe('patch-backup', () => {
471472
)
472473

473474
// Create files
474-
await Promise.all(files.map((file, i) => writeFile(file, `content ${i}`)))
475+
await Promise.allSettled(files.map((file, i) => writeFile(file, `content ${i}`)))
475476

476477
// Create backups sequentially
477478
for (const file of files) {

0 commit comments

Comments
 (0)