mercredi 29 juillet 2020

How to mock VueAxios in jest

I want to test my Api functions which are on separate file outside vue component. Inside this methods i call api by Vue.axios, and i can't find the way to mock and test it like in this post:

How do I test axios in jest

example method:

cancelAuction: function (auction_id) {
    if (validateApiInt(auction_id)) {
      return Vue.axios.delete(`/auctions/${auction_id}`);
    }
    return {};
  },

example usage:

const response = await AuctionApi.cancelAuction(id);

Aucun commentaire:

Enregistrer un commentaire