Skip to content

Commit 5a26525

Browse files
committed
fix(test): make dlx tests sequential to prevent race conditions
Tests were failing in CI due to parallel execution causing interference: - Multiple tests modifying the same shared DLX directory - Race conditions between directory creation/deletion operations - Windows timing issues with sync delete + async check Fixes: - Mark test suite as sequential (describe.sequential) - Use async fs.promises.rm() for async existence checks - Ensures proper test isolation and consistent timing Resolves CI failures on Node 20/22/24 across Ubuntu and Windows.
1 parent 69b8c15 commit 5a26525

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

test/dlx.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
} from '@socketsecurity/lib/dlx'
2929
import { getSocketDlxDir } from '@socketsecurity/lib/paths'
3030

31-
describe('dlx', () => {
31+
describe.sequential('dlx', () => {
3232
const testPackageName = 'test-package'
3333
const dlxDir = getSocketDlxDir()
3434

@@ -83,9 +83,11 @@ describe('dlx', () => {
8383
})
8484

8585
it('async version should return false when directory does not exist', async () => {
86-
// Ensure it doesn't exist
87-
if (fs.existsSync(dlxDir)) {
88-
fs.rmSync(dlxDir, { recursive: true, force: true })
86+
// Ensure it doesn't exist (use async version for consistency)
87+
try {
88+
await fs.promises.rm(dlxDir, { recursive: true, force: true })
89+
} catch {
90+
// Directory might not exist, which is fine
8991
}
9092
expect(await dlxDirExistsAsync()).toBe(false)
9193
})

0 commit comments

Comments
 (0)