期望断言类型错误-> Expect(...).toExist不是一个函数 [英] Expect assertions type error -> expect(...).toExist is not a function
问题描述
我正在测试一个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屋!