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
15 changes: 13 additions & 2 deletions src/utils/path-resolve.test.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { existsSync, lstatSync, readdirSync, rmSync } from 'node:fs'
import { existsSync, readdirSync, rmSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

Expand Down Expand Up @@ -54,7 +54,18 @@ function cleanupBrokenSymlinks(dirPath: string): void {
// Clean up broken symlinks before loading node_modules.
cleanupBrokenSymlinks(rootNmPath)

const mockedNmCallback = mockFs.load(rootNmPath)
// Load node_modules with error handling for any remaining issues.
const mockedNmCallback = (() => {
try {
return mockFs.load(rootNmPath)
} catch (e) {
// If loading fails due to broken symlinks or missing files, return empty mock.
console.warn(
`Warning: Failed to load node_modules for mock-fs: ${e instanceof Error ? e.message : String(e)}`,
)
return {}
}
})()

function mockTestFs(config: FileSystem.DirectoryItems) {
return mockFs({
Expand Down