-
Notifications
You must be signed in to change notification settings - Fork 102
Open
Description
How to Mock redaxios like in this code
import { beforeEach, describe, expect, test, vi } from 'vitest'
import { createUser, fetchUsers } from './users.service'
import axios from 'axios'
vi.mock('axios')
describe('Users Service', () => {
describe('fetchUsers', () => {
test('makes a GET request to fetch users', async () => {
const usersMock = [{ id: 1 }, { id: 2 }]
axios.get.mockResolvedValue({
data: usersMock,
})
})
})
})Metadata
Metadata
Assignees
Labels
No labels