测试vue组​​件时如何在笑话快照中添加样式?

时间:2019-05-22 13:51:14

标签: vue.js jestjs vue-test-utils

我曾尝试使用Jest对Vue SFC进行快照测试。而且我错过了生成的快照文件中的样式,只有类名。可以在快照中添加样式规则吗?

<template>
  <div class="woof"></div>
</template>

<script>
  import Vue from 'vue-class-component';

  export default class Component extends Vue {};
</script>

<style lang="scss">
  .woof {
    background-color: red; // <- this part is missing inside snapshot file
  }
</style>
import { shallowMount } from '@vue/test-utils';
import Component from './Component.vue';

describe('Component testing', () => {
  it('looks as expected', () => {
    const wrapper = shallowMount(Component);

    expect(wrapper).toMatchSnapshot();
  });
});

0 个答案:

没有答案