Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.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

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
Unit testing vue测试返回错误包装器。findComponent不是函数_Unit Testing_Vue.js_Vue Test Utils - Fatal编程技术网

Unit testing vue测试返回错误包装器。findComponent不是函数

Unit testing vue测试返回错误包装器。findComponent不是函数,unit-testing,vue.js,vue-test-utils,Unit Testing,Vue.js,Vue Test Utils,我在Vue中进行了一次测试: import { shallowMount } from '@vue/test-utils' import InputComponent from '@/modules/nsignalsimfrontend/components/inputs/InputComponent' import 'regenerator-runtime/runtime' describe('InputComponent.vue', () => { it('test', as

我在Vue中进行了一次测试:

import { shallowMount } from '@vue/test-utils'
import InputComponent from '@/modules/nsignalsimfrontend/components/inputs/InputComponent'
import 'regenerator-runtime/runtime'

describe('InputComponent.vue', () => {
    it('test', async () => {
        const $t = () => {}
        const value = 'Foo'
        const wrapper = shallowMount(InputComponent, {
            mocks: { $t },
            propsData: {
                value,
            },
        })
        
        expect(wrapper.props().value).toBe(value)

        const input = wrapper.findComponent({ ref: 'input' })
        input.element.value = value
        await input.trigger('keyup.enter')

        expect(wrapper.emitted().submit).toBeTruthy()
        expect(wrapper.emitted().submit[0][0]).toEqual(value)
    })
})
当我在本地运行此测试时,工作正常,但当我在build中尝试Jenkins的build application时,我有npm run test:unit我有一个错误:

wrapper.findComponent不是函数


我有@vue/test-utils版本1.0.3,我也有同样的问题。将@vue/test-utils从1.0.0-beta.31升级到1.1.2为我解决了这个问题。

我也遇到了同样的问题。将@vue/test-utils从1.0.0-beta.31升级到1.1.2为我解决了这个问题。

我在@vue/test-utils从1.0.0-beta.29上也遇到了同样的问题,但是您可以使用wrapper.find按ref选择。 示例:wrapper.find{ref:'input'}
如果您想按组件查找,您可以只使用wrapper.findComponent

我在1.0.0-beta.29版本的@vue/test-utils中遇到了相同的问题,但是您可以使用wrapper.find按ref选择。 示例:wrapper.find{ref:'input'}
如果您想按组件查找,只需包装。findComponent

谢谢,这很有用。谢谢,这很有用。