Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vue.js 如何使用jest在vue和vuetify中对变量进行单元测试?_Vue.js_Jestjs_Vuetify.js_Vue Test Utils - Fatal编程技术网

Vue.js 如何使用jest在vue和vuetify中对变量进行单元测试?

Vue.js 如何使用jest在vue和vuetify中对变量进行单元测试?,vue.js,jestjs,vuetify.js,vue-test-utils,Vue.js,Jestjs,Vuetify.js,Vue Test Utils,这可能很简单 我有一个组件,它通过道具呈现接收消息,并以v-card-text呈现。它并没有以一种最佳的方式做到这一点,整个v-if是混乱的,但它可以工作 <template> <!-- Needed to be rendered big --> <div v-if="start == true" class="ma-0"> <v-card class="text-xs-right" dark color="rgb(0,

这可能很简单

我有一个组件,它通过道具呈现接收消息,并以v-card-text呈现。它并没有以一种最佳的方式做到这一点,整个v-if是混乱的,但它可以工作

<template>

    <!-- Needed to be rendered big -->
    <div v-if="start == true" class="ma-0">
        <v-card class="text-xs-right" dark color="rgb(0,140,69)" height="50" width="1060" >

            <v-btn dark text icon @click= "isOpen = !isOpen;"  color="rgb(0,140,69)" > 
                <v-icon dark>fullscreen</v-icon>
            </v-btn>

            <v-btn class="mx-2" icon dark small color="rgb(0,140,69)">
                <v-icon dark>thumb_up</v-icon>
            </v-btn>

        </v-card>

        <v-card  v-model='text' color="" height="200" width="1060"> 
            <v-card-text ref="tcardbig" color="rgb(0,140,69)" style="color:rgb(0,140,69);display:flex;height:100%;justify-content:center;" class="display-2 font-weight-black align-center"> {{text}}</v-card-text>  
        </v-card>
    </div>

    <!-- Needed to be rendered small -->
    <div v-else class="ma-2">
        <v-card class="text-xs-right" dark color="rgb(0,140,69)" height="50" width="500" >

            <v-btn dark text icon @click= "isOpen = !isOpen;"  color="rgb(0,140,69)" > 
                <v-icon dark>fullscreen</v-icon>
            </v-btn>

            <v-btn class="mx-2" icon dark small color="rgb(0,140,69)">
                <v-icon dark>thumb_up</v-icon>
            </v-btn>

        </v-card>

        <v-card  v-model='text' color="" height="350" width="500"> 
            <v-card-text ref="tcardsmall" color="rgb(0,140,69)" style="color:rgb(0,140,69);display:flex;height:100%;justify-content:center;" class="display-2 font-weight-black align-center"> {{text}}</v-card-text>  
        </v-card>
    </div>


</template>

<script>
export default {
  data(){
      return {
          text: 'lorem ipsum',  
          start: true
      }
  },
  props: ['textProps', 'startProps'],
  mounted(){
      this.text = this.textProps
      this.start = this.startProps
  }
}
</script>

import {createLocalVue, mount} from '@vue/test-utils'
import textCard from './textCard.vue'
import Vue from 'vue'
import Vuetify from 'vuetify'

Vue.use(Vuetify)
const localVue = createLocalVue()



describe('textCard.vue', () => {

    const wrapper = mount(textCard, 
        {
            localVue,
            vuetify,
            propsData: {
              text: 'Random Text',
              start: false
            },
        }
        )
    it('renders a vue instance', () => {
        expect(mount(textCard).isVueInstance()).toBe(true);
    });

    const content = wrapper.find({ ref: 'tcardsmall' })


    it('Checks the if the variable text is correct', () => {
        expect(content.selector).toMatch('Random Text')
      })

}

)