I am applying toBeA() method on expect() and it gives the error TypeError: Cannot read property 'toBeA' of undefined how can I apply these methods by chaining.
utils.test.js code
const expect = require('expect');
const utils = require('./utils');
it('should add two numbers',() => {
var res = utils.add(44,11);
expect(res).toBe(55).toBeA('number'); ----> here it gives the above error.
});
it('Object should be equal',() => {
expect([1,2,5,7]).toInclude(5); ---> here it gives the error TypeError: expect(...).toInclude is not a function
});
utils.js code
module.exports.add = (a, b) => a + b ;
How do I fix this issue ?
The
expect
package API has changed since Jest took ownership and they renamed some of the methods. If you check the code of theexpect
package you will find out thetoBeA
andtoInclude
methods are not available anymore.You can change your implementation with these methods that are available in the v.23.4.0.