Skip to content

Commit bc80b19

Browse files
committed
test(patch): use Promise.allSettled for cleanup operations
Convert all patch test cleanup functions to use Promise.allSettled to ensure all node_modules and patches directories are removed even if one deletion fails. This prevents test pollution from failed cleanup operations.
1 parent e4c7471 commit bc80b19

8 files changed

Lines changed: 9 additions & 9 deletions

packages/cli/src/commands/patch/cmd-patch-cleanup.test.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const pnpmFixtureDir = path.join(fixtureBaseDir, 'pnpm')
1414

1515
async function cleanupNodeModules() {
1616
// Clean up node_modules from all package manager directories.
17-
Promise.all([
17+
Promise.allSettled([
1818
fs.rm(path.join(pnpmFixtureDir, 'node_modules'), {
1919
force: true,
2020
recursive: true,

packages/cli/src/commands/patch/cmd-patch-discover.test.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const pnpmFixtureDir = path.join(fixtureBaseDir, 'pnpm')
1515

1616
async function cleanupNodeModules() {
1717
// Clean up node_modules from all package manager directories.
18-
Promise.all([
18+
Promise.allSettled([
1919
fs.rm(path.join(pnpmFixtureDir, 'node_modules'), {
2020
force: true,
2121
recursive: true,

packages/cli/src/commands/patch/cmd-patch-download.test.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const pnpmFixtureDir = path.join(fixtureBaseDir, 'pnpm')
1414

1515
async function cleanupNodeModules() {
1616
// Clean up node_modules from all package manager directories.
17-
Promise.all([
17+
Promise.allSettled([
1818
fs.rm(path.join(pnpmFixtureDir, 'node_modules'), {
1919
force: true,
2020
recursive: true,

packages/cli/src/commands/patch/cmd-patch-get.test.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const pnpmFixtureDir = path.join(fixtureBaseDir, 'pnpm')
1616

1717
async function cleanupNodeModules() {
1818
// Clean up node_modules from all package manager directories.
19-
await Promise.all([
19+
await Promise.allSettled([
2020
safeDelete(path.join(pnpmFixtureDir, 'node_modules')),
2121
safeDelete(path.join(fixtureBaseDir, 'npm/node_modules')),
2222
safeDelete(path.join(fixtureBaseDir, 'yarn/node_modules')),
@@ -25,7 +25,7 @@ async function cleanupNodeModules() {
2525

2626
async function cleanupPatchesDir() {
2727
// Clean up generated patches directories.
28-
await Promise.all([
28+
await Promise.allSettled([
2929
safeDelete(path.join(pnpmFixtureDir, 'patches')),
3030
safeDelete(path.join(process.cwd(), 'patches')),
3131
])

packages/cli/src/commands/patch/cmd-patch-info.test.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const pnpmFixtureDir = path.join(fixtureBaseDir, 'pnpm')
1414

1515
async function cleanupNodeModules() {
1616
// Clean up node_modules from all package manager directories.
17-
Promise.all([
17+
Promise.allSettled([
1818
fs.rm(path.join(pnpmFixtureDir, 'node_modules'), {
1919
force: true,
2020
recursive: true,

packages/cli/src/commands/patch/cmd-patch-list.test.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const pnpmFixtureDir = path.join(fixtureBaseDir, 'pnpm')
1414

1515
async function cleanupNodeModules() {
1616
// Clean up node_modules from all package manager directories.
17-
Promise.all([
17+
Promise.allSettled([
1818
fs.rm(path.join(pnpmFixtureDir, 'node_modules'), {
1919
force: true,
2020
recursive: true,

packages/cli/src/commands/patch/cmd-patch-rm.test.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const originalManifest = {
4242

4343
async function cleanupNodeModules() {
4444
// Clean up node_modules from all package manager directories.
45-
Promise.all([
45+
Promise.allSettled([
4646
fs.rm(path.join(pnpmFixtureDir, 'node_modules'), {
4747
force: true,
4848
recursive: true,

packages/cli/src/commands/patch/cmd-patch.test.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const pnpmFixtureDir = path.join(fixtureBaseDir, 'pnpm')
1414

1515
async function cleanupNodeModules() {
1616
// Clean up node_modules from all package manager directories.
17-
await Promise.all([
17+
await Promise.allSettled([
1818
fs.rm(path.join(pnpmFixtureDir, 'node_modules'), {
1919
force: true,
2020
recursive: true,

0 commit comments

Comments
 (0)