Read more

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

Henning Koch
January 29, 2020Software engineer at makandra GmbH

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))
  })
})
Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

Also see Expecting objects as method invocation arguments.

Posted by Henning Koch to makandra dev (2020-01-29 10:19)