on applying toBeA() method on expect().toBe() it gives an error that cann't read the property o


I am applying toBeA() method on expect() and it gives the error <strong>TypeError: Cannot read property 'toBeA' of undefined</strong> how can I apply these methods by chaining.

<strong>utils.test.js code</strong>

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 });

<strong>utils.js code</strong>

module.exports.add = (a, b) => a + b ;

How do I fix this issue ?


The expect package API has changed since <a href="https://jestjs.io/" rel="nofollow">Jest</a> took ownership and they renamed some of the methods. If you check the <a href="https://github.com/facebook/jest/blob/master/packages/expect/src/matchers.js" rel="nofollow">code</a> of the expect package you will find out the toBeA and toInclude methods are not available anymore.

You can change your implementation with these methods that are available in the v.23.4.0.

it('should add two numbers',() => { var res = utils.add(44,11); expect(typeof res).toBe('number'); expect(res).toBe(55); }); it('Object should be equal',() => { expect([1,2,5,7]).toContain(5); });


  • How to Pass Name/Value Pairs to an ASMX Web Method?
  • AngularJS Jasmine test: TypeError: 'undefined' is not an object
  • Test ES6 modules with Jest
  • Why won't $location.path trigger a $routeChangeStart in the controller?
  • Date conversion in nodejs and postgres
  • Perform a simple select query in Firebase Firestore
  • How To Draw More Precise Lines using Core Graphics and CALayer
  • Openshift node app failed to start
  • import error with python-mysql-connector 1.16, django 1.6, and python 3.2.3
  • Django Class view didn't return an HttpResponse object. It returned None instead
  • android Navigation Bar hiding and persantage of usable screen overlap
  • How to resolve permission denied maybe missing internet permission?
  • Access variable of ScriptContext using Nashorn JavaScript Engine (Java 8)
  • How Lists (specifically, RecyclerView with CardViews) in Android work
  • Code in Job's Script Block after Start-Process Does not Execute
  • rspec simple example getting error on request variable in integration test
  • C: Incompatible pointer type initializing
  • How to attach a node.js readable stream to a Sendgrid email?
  • Exception “firebase.functions() takes … no argument …” when specifying a region for a Cloud Function
  • Display issues when we change from one jquery mobile page to another in firefox
  • Deselecting radio buttons while keeping the View Model in synch
  • req.body is undefined - nodejs
  • Spray.io: When (not) to use non-blocking route handling?
  • AES padding and writing the ciphertext to a disk file
  • VS2008 Enable C++ Exception with SEH
  • Modifying destination and filename of gulp-svg-sprite
  • JSON with duplicate key names losing information when parsed
  • Importing jscolor library in angular 2
  • Jquery - Jquery Wysiwyg return html as a string
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • How to delete a row from a dynamic generate table using jquery?
  • using HTMLImports.whenReady not working in chrome
  • JTable with a ScrollPane misbehaving
  • Angular 2 constructor injection vs direct access
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Java static initializers and reflection
  • Android Google Maps API OnLocationChanged only called once
  • Authorize attributes not working in MVC 4
  • EntityFramework adding new object to nested object collection
  • UserPrincipal.Current returns apppool on IIS