Expect assertions type error -> expect(…).toExist

2019-04-05 12:40发布

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);
})

the error showed:

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

how can I resolve this issue?? TIA.

标签: node.js mocha
1条回答
劳资没心,怎么记你
2楼-- · 2019-04-05 13:02

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

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()'.

查看更多
登录 后发表回答