mjackson / expect

Write better assertions
MIT License
2.29k stars 117 forks source link

toNotExist() issue #238

Closed manurueda closed 6 years ago

manurueda commented 6 years ago

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

ljharb commented 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

elgelbo commented 6 years ago

Same for me. On v22.0.3. Same test worked with calling alias toBeFalsy

ljharb commented 6 years ago

@elgelbo expect v21+ is maintained by jest; that's not this repo.

mk2683 commented 6 years ago

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

ljharb commented 6 years ago

@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.

ioanzicu commented 6 years ago

In expect.js library was made next changes

.toExist() // aka: toBeTruthy()

.toNotExist() // aka: toBeFalsy() From official expect.js page https://devhints.io/expectjs

tonyfrenzy commented 5 years ago

Given testedEntity == null

expect(testedEntity).toBeFalsy() or expect(testedEntity).toBe(null) works as well