I have the function in the Races.vue file, the front end is working fine but not testing
getRaces: function () {
axios.get(URL)
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error);
this.errored = true;
})
.finally(() => {
this.loading = false;
})
}
And when I try to test it, after adding vi.mock part, will give "TypeError: Cannot read properties of undefined (reading 'then')" error
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
import { shallowMount, mount, flushPromises } from '@vue/test-utils'
import Races from '../Races.vue'
import axios from 'axios'
vi.mock("axios", () => {
return {
default: {
get: vi.fn(),
},
};
});
Any idea on how to solve this? Thank you so much