import { mount } from '@vue/test-utils';
import paynow from '../pages/pay';
import axios from "axios";
import Vue from 'vue'
jest.mock("axios", () => ({
get: () => Promise.resolve({ data: [{ val: 1 }] })
}));
describe("paynow.vue", () => {
it("mocking the axios call to get posts should work", async () => {
var wrapper = mount(paynow);
wrapper.vm.pay()
});
});
But i am getting this error after running it.
TypeError: Cannot read property 'get' of undefined
axios is injected inplugin then why it is showing undefined
I am using nuxt + jest for uniit testing , when id testing a page it has axios call in method like this
IN pay.vue
and test file pay.spec.js
But i am getting this error after running it. TypeError: Cannot read property 'get' of undefined axios is injected inplugin then why it is showing undefined