1: first of all, I found a lot of web addresses by myself, but they didn"t work, and even the official website didn"t seem to work.
2: my question is how to simulate async
3: the project is built using vue-cli3 with its own test module
req.js encapsulates axios, and does some parameter processing before sending it
export default function req () {
// ...
axios.post()
}
table.vue calls the fetch method to get asynchronous data
<template>...</template>
<script>
import req from "@/utils/req"
export default {
methods: {
fetch () {
// ...
req(data).then(() => {
// ...
})
}
}
}
</script>
< H2 > Supplementary test code < / H2 >
jest.mock("@/utils/req")
// wrapper = mount(vue)
it("-sharp-sharp fetch data success", (done) => {
wrapper.vm.fetch()
wrapper.vm.$nextTick(() => {
expect(wrapper.vm.cloneConfig).toEqual(mockData)
done()
})
})
table.vuefetchreqmock
< H2 > reported this error. = 3 = I don"t understand. I use the table component of element. In my fetch function, req gets the data and binds it < / H2 >.