期望断言类型错误-> Expect(...).toExist不是一个函数 [英] Expect assertions type error -> expect(...).toExist is not a function

查看:130
本文介绍了期望断言类型错误-> Expect(...).toExist不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试一个nodejs应用程序.运行测试时在哪里找到此错误.测试脚本如下:

I'm testing a nodejs app. Where I find this error when I run the test. The test script is below:

.expect( (res) => {
    expect(res.headers['x-auth']).toExist();
    expect(res.body._id).toExist();
    expect(res.body.email).toBe(email);
})

错误显示:

TypeError: expect(...).toExist is not a function

我该如何解决这个问题? TIA.

how can I resolve this issue?? TIA.

推荐答案

期望断言库已更改所有权.它被移交给了Jest团队,他们凭着无限的智慧创建了一个新的 API .

The expect assertion library has changed ownership. It was handed over to the Jest team, who in their infinite wisdom, created a new API.

您现在必须使用'toBeTruthy()'的"toExist()". 您仍然可以像以前一样安装Expect,"npm install expect --save-dev",当前版本为21.2.1.大多数方法名称将保持不变,除了少数名称,包括"toExist()".

You must now use 'toBeTruthy()' instead of 'toExist()'. You can still install expect as before, "npm install expect --save-dev", which is currently at version 21.2.1.Most methods names will remain unchanged except for a few, including 'toExist()'.

这篇关于期望断言类型错误-> Expect(...).toExist不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆