【发布时间】:2019-05-16 11:10:05
【问题描述】:
我在我的组件中有这个方法,它使用 axios 进行 API 调用,我查看了有关如何测试它的文档,但我似乎无法弄清楚如何去做。任何帮助将不胜感激。
loadContents() {
axios.get('/vue_api/content/' + this.slug).then(response => {
this.page_data = response.data.merchandising_page
}).catch(error => {
console.log(error)
})
},
【问题讨论】:
-
模拟 axios?请参阅文档:jestjs.io/docs/en/mock-functions
标签: javascript unit-testing vue.js vuejs2 jestjs