Skip to content

Commit

Permalink
test mocking axios
Browse files Browse the repository at this point in the history
  • Loading branch information
havok2063 committed Aug 6, 2024
1 parent bf36304 commit 91f4874
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/views/__tests__/Search.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect, beforeEach } from 'vitest'
import { vi, describe, it, expect, beforeEach } from 'vitest'
import { mount } from '@vue/test-utils'

import { createVuetify } from 'vuetify'
Expand All @@ -9,8 +9,18 @@ import * as directives from 'vuetify/directives'
import { createTestingPinia } from '@pinia/testing'

import Search from '../Search.vue'
//import axiosInstance from '@/axios'


// Mock the specific axiosInstance
vi.mock('@/axios', () => ({
default: {
get: vi.fn(() => Promise.resolve({ data: 'mocked data' })),
post: vi.fn(),
// Add other methods as needed
},
}));

describe('Search', () => {
const vuetify = createVuetify({ components, directives })
const pinia = createTestingPinia()
Expand Down

0 comments on commit 91f4874

Please sign in to comment.