Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions packages/vitest/src/runtime/mocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,10 @@ export class VitestMocker {
return null
}

const files = readdirSync(mockFolder)
const baseOriginal = basename(path)

function findFile(files: string[], baseOriginal: string): string | null {
function findFile(mockFolder: string, baseOriginal: string): string | null {
const files = readdirSync(mockFolder)
for (const file of files) {
const baseFile = basename(file, extname(file))
if (baseFile === baseOriginal) {
Expand All @@ -326,7 +326,7 @@ export class VitestMocker {
}
else {
// find folder/index.{js,ts}
const indexFile = findFile(readdirSync(path), 'index')
const indexFile = findFile(path, 'index')
if (indexFile) {
return indexFile
}
Expand All @@ -336,7 +336,7 @@ export class VitestMocker {
return null
}

return findFile(files, baseOriginal)
return findFile(mockFolder, baseOriginal)
}

const dir = dirname(path)
Expand Down
File renamed without changes.