Vue.js 带Jest的Vue单元测试:如何测试组件中是否有一个特定映像

Vue.js 带Jest的Vue单元测试:如何测试组件中是否有一个特定映像,vue.js,jestjs,vue-test-utils,Vue.js,Jestjs,Vue Test Utils,我正在使用vue test utils和Jest进行单元测试。我正在测试的组件有几个图像,但其中一个图像比其他图像更重要,我想测试一下,看看它是否存在 我看过文件了[ 及[ 这是我的密码 具有图像的组件: <template> <img :scr="require('./images/image1.png')" class="image1"/> <!-- other code below - not testing in this case -->

我正在使用vue test utils和Jest进行单元测试。我正在测试的组件有几个图像,但其中一个图像比其他图像更重要,我想测试一下,看看它是否存在

我看过文件了[ 及[

这是我的密码

具有图像的组件:

<template>
   <img :scr="require('./images/image1.png')" class="image1"/>
   <!-- other code below -  not testing in this case -->
</template>
我的错误是:“wrapper.get”不是函数


我想获得一些帮助来正确测试我的组件中是否有映像,以及如何在单元测试中使用get()断言。

使我的测试工作正常的代码是:

import component from '@/src/stuff/component';
import { mount } from 'vue-test-utils';

describe('component', () => {

const wrapper = mount(component);

test('Is there an image in the component', () => {
const img = wrapper.find('.image1'))
expect(img.is('.image1')).toBe(true)
expect(wrapper.get('image1'))

});
test("Check that the specific image exists", () => {
const img = wrapper.findAll('.image1'));
expect(img.length).toBe(1);
});