Problem Statement
How do you mock API calls in Vue tests?
Explanation
Abstract HTTP into a module and mock it with vi.mock/jest.mock. For Axios, mock instance methods (get/post). Resolve with canned data or force rejections to test error paths.
Code Solution
SolutionRead Only
vi.mock('../api', () => ({ fetchUsers: vi.fn(() => Promise.resolve([{id:1}])) }))