0👍
It depends on how you set the global this.$api
, but if you want to mock an entire file (especially using the default export), you should use the __esModule
property:
jest.mock('./esModule', () => ({
__esModule: true, // this property makes it work
default: 'mockedDefaultExport',
namedExport: jest.fn(),
}));
More explanations on Jest mock default and named export.
- [Vuejs]-Set Index in computed function
- [Vuejs]-Vuetify application breaks upon failed v-img source require statement
Source:stackexchange.com