ReactJS测试:无法读取未定义的属性“具有”

时间:2018-11-07 18:28:53

标签: reactjs jestjs enzyme

我正在尝试为我的代码编写我的第一个测试,但是我很难让最基本的功能正常工作。这是我所拥有的:

@Get('revision-count')
async countRevisions(@User() user, @Param() params) {

    user.count ++;

    return {
        status: 'success',
        data: {
            rand: user.count,
        }
    };
}

我收到“ TypeError:无法读取未定义的属性'have',”,我真的不确定自己在做什么。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:2)

expect(wrapper.find('div')).toHaveLength(1);

https://jestjs.io/docs/en/expect#tohavelengthnumber