Exclusive Clothing Sale On Flipkart

Get up to 50% off on our latest collection.

Shop Now

toBeDefined and toBeUndefined Jasmine matcher

  toBeDefined and toBeUndefined Jasmine matcher


toBeDefined()

The 'toBeDefined' matcher should be applied successfully to compares against defined

it("Jasmine matcher - toBeDefined", function() {

  var MyObj = {

    foo: "foo"

  };

  var Myfunction = (function() {})();

  var strUndefined;

  expect("The Dotnet office").toBeDefined();

  expect(MyObj).toBeDefined();

  expect(MyObj.foo).toBeDefined();

  expect(Myfunction).not.toBeDefined();

  expect(strUndefined).not.toBeDefined();

});

'toBeUndefined()

The 'toBeUndefined' matcher should be applied successfully to compares against undefined

it("Jasmine matcher - toBeUnDefined", function() {

  var MyObj = {

          foo: "foo"

        };

  var Myfunction = (function() {})();

  var strUndefined;

    expect(MyObj).not.toBeUndefined();

    expect(MyObj.foo).not.toBeUndefined();     

    expect(Myfunction).toBeUndefined();

    expect(strUndefined).toBeUndefined();

});

 you can learn more on it from below video




Share this

Related Posts

Previous
Next Post »

Exclusive Clothing Sale On Flipkart

Get up to 50% off on our latest collection.

Shop Now