Expect assertions type error -> expect(…).toExist is not a function

前端 未结 2 1249
半阙折子戏
半阙折子戏 2021-02-19 23:26

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\']).toE         


        
相关标签:
2条回答
  • 2021-02-19 23:44

    If you are using Jest you can also use 'toBeDefined()'

    0 讨论(0)
  • 2021-02-19 23:45

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

    0 讨论(0)
提交回复
热议问题