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 money motivation

Opscomplete powered by makandra brand

Save money by migrating from AWS to our fully managed hosting in Germany.

  • Trusted by over 100 customers
  • Ready to use with Ruby, Node.js, PHP
  • Proactive management by operations experts
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)