Jasmine: Test that an object is an instance of a given class

Posted . Visible to the public.

To test that an object was constructed by a given constructor function, use jasmine.any(Klass):

describe('plus()', function() {
  it ('returns a number', function() {
    let result = plus(1, 2)
    expect(result).toEqual(jasmine.any(Number))
  })
})

Also see Expecting objects as method invocation arguments.

Henning Koch
Last edit
Henning Koch
Keywords
javascript, instanceof
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2020-01-29 09:19)