Expect assertion type errors & # 8594; expect (...). ToExist is not a function

I am testing a nodejs application. Where do I find this error when I run the test. Test script 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 solve this problem? TIA.

+11
source share
2 answers

A library of pending expectations has changed ownership. It was transferred to the Jest team, which in its infinite wisdom created a new API .

'toBeTruthy()' 'toExist()'. - , , "npm install expect --save-dev", 21.2.1. , , "toExist()".

+25

Jest, 'toBeDefined()'

0

Source: https://habr.com/ru/post/1686445/


All Articles