Skip to content

fix(test): use mockReturnValue for synchronous fs mocks#3286

Merged
kamilmysliwiec merged 2 commits intov12.0.0from
copilot/sub-pr-3280-one-more-time
Mar 11, 2026
Merged

fix(test): use mockReturnValue for synchronous fs mocks#3286
kamilmysliwiec merged 2 commits intov12.0.0from
copilot/sub-pr-3280-one-more-time

Conversation

Copy link

Copilot AI commented Mar 11, 2026

fs.readdirSync and fs.readFileSync mocks in the FileSystemReader spec were using mockResolvedValue, which wraps the return in a Promise. Since these are synchronous APIs, the unit under test would receive a Promise instead of the expected string/string[], masking real behavior.

Change

// Before
vi.mock('fs', () => ({
  readdirSync: vi.fn().mockResolvedValue([]),
  readFileSync: vi.fn().mockResolvedValue('content'),
}));

// After
vi.mock('fs', () => ({
  readdirSync: vi.fn().mockReturnValue([]),
  readFileSync: vi.fn().mockReturnValue('content'),
}));

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: kamilmysliwiec <23244943+kamilmysliwiec@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback from PR #3280 for v12.0.0 major release fix(test): use mockReturnValue for synchronous fs mocks Mar 11, 2026
@kamilmysliwiec kamilmysliwiec marked this pull request as ready for review March 11, 2026 15:02
@kamilmysliwiec kamilmysliwiec merged commit 8d89b2c into v12.0.0 Mar 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants