相关疑难解决方法(0)

如何编写在vue组件中模拟$ route对象的测试

我有一个包含类似语句成分this.$route.fullPath,我应该怎么嘲笑的值fullPath$route对象,如果我想测试组件?

unit-testing sinon vue-component vue-loader vuejs2

24
推荐指数
3
解决办法
2万
查看次数

如何在 vue 组合 api 组件中使用 jest 进行单元测试?

我正在用 jest 为 vue.js 中的组合 API 组件编写单元测试。

但是我无法访问组合 API 的 setup() 中的函数。

指标.vue

<template>
  <div class="d-flex flex-column justify-content-center align-content-center">
    <ul class="indicator-menu d-flex justify-content-center">
      <li v-for="step in steps" :key="step">
        <a href="#" @click="updateValue(step)" :class="activeClass(step, current)"> </a>
      </li>
    </ul>
    <div class="indicator-caption d-flex justify-content-center">
      step
      <span> {{ current }}</span>
      from
      <span> {{ steps }}</span>
    </div>
  </div>
</template>

<script lang="ts">
import {createComponent} from '@vue/composition-api';

export default createComponent({
  name: 'Indicator',
  props: {
    steps: {
      type: Number,
      required: true
    },
    current: {
      type: Number,
      required: true
    } …
Run Code Online (Sandbox Code Playgroud)

unit-testing typescript vue.js jestjs vue-composition-api

15
推荐指数
1
解决办法
4241
查看次数