mjackson / expect

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

expect(2).toBeA('number') is not working on version 21.0.0 #229

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi,

I have just installed expect with npm. Below is the snippet of my package.json file:

"devDependencies": {
    "expect": "^21.0.0",
    "mocha": "^3.5.0"
  }

When I run the test, it throws the following error:

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

Can anyone please sort out the issue? Thanks,

ljharb commented 7 years ago

v21+ of expect is maintained by jest - please file it there: https://github.com/facebook/jest/issues/new

jharris4 commented 6 years ago

@nadeemjamali .toBeA should now be replaced with .toBeInstanceOf.

You can see the code mod source here: https://github.com/skovhus/jest-codemods/blob/master/src/transformers/expect.js

xlight05 commented 6 years ago

I have used "expect@1.20.2 " and it fixed the issue.

mdashikar 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 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(), toBeA()'