第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

單元測(cè)試包含帶有插槽的 Vuetify 數(shù)據(jù)表的 Vue 組件

單元測(cè)試包含帶有插槽的 Vuetify 數(shù)據(jù)表的 Vue 組件

qq_笑_17 2022-08-04 15:53:12
我正在嘗試使用嵌套組件對(duì)簡(jiǎn)單組件進(jìn)行單元測(cè)試。頁(yè)面在瀏覽器中正確呈現(xiàn),但我似乎無(wú)法編寫(xiě)有效的Jest測(cè)試。v-data-table問(wèn)題似乎出在我用于插槽的模板上 - 我直接從文檔中提取了它。當(dāng)我用屬性注釋掉模板時(shí),測(cè)試執(zhí)行正常。v-slotPeople.vue:<template>  <v-data-table    :headers="headers"    :items="people"    disable-pagination    disable-sort    disable-filtering    hide-default-footer    :loading="!people"  >    <template v-slot:item.id="{ item }">      <v-icon>        mdi-link-variant      </v-icon>      <router-link        :to="{ name: 'assignments', query: { assignee_id: item.id } }"        >Link</router-link      >    </template>  </v-data-table></template><script>export default {  name: "People",  data: () => ({    headers: [      {        text: "Name",        value: "first_name"      },      {        text: "Assignment link",        value: "id"      }    ]  }),  props: {    people: {      type: Array,      required: true    }  }};</script>People.spec.js:import { shallowMount } from "@vue/test-utils";import People from "@/components/People.vue";function getMountedComponent(Component, propsData) {  return shallowMount(Component, { propsData });}const propsData = {  people: [{ id: 1 }]};describe("headers", () => {  it("contains name and assignment", () => {    expect(getMountedComponent(People, propsData).vm.headers).toEqual([      {        text: "Name",        value: "first_name"      },      {        text: "Assignment link",        value: "id"      }    ]);  });});錯(cuò)誤信息:  console.error node_modules/vue/dist/vue.runtime.common.dev.js:621    [Vue warn]: Error in render: "TypeError: Cannot read property 'item' of undefined"    found in    ---> <VDataTable>           <People>             <Root>  console.error node_modules/vue/dist/vue.runtime.common.dev.js:1884    TypeError: Cannot read property 'item' of undefined
查看完整描述

1 回答

?
慕娘9325324

TA貢獻(xiàn)1783條經(jīng)驗(yàn) 獲得超5個(gè)贊

我遇到了同樣的問(wèn)題,發(fā)現(xiàn)如果你把 包裝在 一個(gè) 中,測(cè)試就會(huì)成功。由于某種原因,當(dāng) 是模板的根元素時(shí),在 Jest 中失敗。v-data-tabledivshallowMountv-data-table



查看完整回答
反對(duì) 回復(fù) 2022-08-04
  • 1 回答
  • 0 關(guān)注
  • 167 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)