【发布时间】:2019-03-17 23:09:30
【问题描述】:
我有一个使用quasar-cli 生成的类星体应用程序。
对于这样的应用程序,如何将单元测试集成到像 Jest 这样的测试运行程序中?
我已将 this 添加到我的 Jest 配置中
"moduleNameMapper": {
"quasar": "<rootDir>/node_modules/quasar-framework"
}
很遗憾,Jest 回来报告
Cannot find module 'quasar' from 'index.vue'
这是Vue文件的sn-p
<template>
<div style="padding-top: 20px" v-if="refund.type != null ">
<q-btn :label="'Issue ' + ( currency(refund.amount)) + ' Refund'" :disable="refund.amount <= 0" @click="issueRefund()" color="green" class="full-width" :loading="noteLoading" />
</div>
</template>
<script>
import { Notify } from "quasar"; // here is where I am using Quasar
issueRefund() {
this.noteLoading = true;
this.$axios
.post(`${BASE_URL}/issue_refund/?secret=${this.secret}`, {
refund: this.refund,
agent_email: this.userEmail,
order_id: this.selectedOrder.id,
agent_name: this.$route.query.user_name,
order_number: this.selectedOrder.order_number,
ticket_id: this.ticketId
})
.then(res => {
this.noteLoading = false;
if ((res.data.res === "success")) {
Notify.create({
position: "bottom",
type: "positive",
message: "Refund Issued."
});
this.selectedOrder = res.data.order;
this.resetRefundObj();
this.$refs.refundDiag.hide();
} else {
Notify.create({
position: "bottom",
type: "negative",
message: res.data.error
});
}
});
},
</script>
【问题讨论】:
-
能分享一下 index.vue 的内容吗?
-
当然,我可以分享一些,因为代码是适当的。我将编辑原始问题@boussadjrabrahim
标签: unit-testing vue.js jestjs quasar-framework