Closed manurueda closed 6 years ago
@jmderueda what version of expect are you using? v21+ is maintained by the jest team; see https://github.com/mjackson/expect#notice
Same for me. On v22.0.3.
Same test worked with calling alias toBeFalsy
@elgelbo expect v21+ is maintained by jest; that's not this repo.
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()'.
@IoanZ1994 that is a very wrong conclusion; that “worked” because it’s a noop - it’s undefined
.
Never use noop matchers, only ever use a matcher that terminates in a function call, for this reason.
In expect.js library was made next changes
.toExist() // aka: toBeTruthy()
.toNotExist() // aka: toBeFalsy()
From official expect.js page https://devhints.io/expectjs
Given testedEntity
== null
expect(testedEntity).toBeFalsy()
or
expect(testedEntity).toBe(null)
works as well
Hi all,
First of all, congrats for the library. I am having issues with toNotExist(). ie: expect(null).toNotExist() outputs TypeError: expect(...).toNotExist is not a function
Thank you, J