tobenull() ,tocontain() ,tobeNan() , toBePositiveInfinity, toBeNegetiveInfinity matcher

 tobenull() ,tocontain() ,tobeNan() , toBePositiveInfinity, toBeNegetiveInfinity matcher

'toBeNull()

The 'toBeNull' matcher should be applied successfully to compare against null


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

  var nullValue = null;

  var valueUndefined;

  var notNull = "notNull";

  expect(null).toBeNull();

  expect(nullValue).toBeNull();

  expect(valueUndefined).not.toBeNull();

  expect(notNull).not.toBeNull();

}); 

'toContain()


The 'toContain' matcher should be applied successfully for finding an item in an array


it("Jasmine matcher -toContain ", function() {
  var MyArray = ["jasmine", "Dotnetoffice", "Tutorials"];
    expect([1, 2, 3]).toContain[2];
    expect([1, 2, 3]).toContain(2,3);
    expect(MyArray).toContain["jasmine"];
    expect([1, 2, 3]).not.toContain(4);
    expect(MyArray).not.toContain("dot");
});

tobeNan()


The tobeNan' matcher should be applied successfully for finding an Un-determined value

it("Jasmine matcher - tobeNan ", function() {
    expect(0 / 0).toBeNaN();
      expect(0 / 5).not.toBeNaN();
}); 

toBePositiveInfinity()


The toBePositiveInfinity ' matcher should be applied successfully for finding an Positive infinity value

it("Jasmine matcher - toBePositiveInfinity ", function() {
 expect(1 / 0).toBePositiveInfinity();
}); 



You can learn it from below Video



Share this

Related Posts

Previous
Next Post »