There are two types of matchers in Jasmine.js, Inbuilt matcher and Custom matchers.
Inbuilt Matcher are the matchers which are inbuilt in the Jasmine framework. The user can easily use it.
The below example displays on how Inbuilt Matcher works with Jasmine framework.
We had already used some matchers in the earlier chapters.
In the above example, toEqual() is the inbuilt matcher which will compare the result of the add() and addAny() methods with the arguments passed to toEqual() matchers.
Custom matcher are the matchers which are not present in the inbuilt system library of Jasmine. These matcher are needed to be defined explicitly(). In the below example, we will see how the custom matcher works.
In the example stated above, validateAge() works as a matcher which is actually validating our age with some range. In this example, validateAge() works as a custom matcher. Add this JS file into SpecRunner.html and run the same. It will produce the below result.
JasmineJS Related Interview Questions
|C++ Interview Questions||Adv Java Interview Questions|
|Core Java Interview Questions||Java Interview Questions|
|JavaMail API Interview Questions||Java collections framework Interview Questions|
|Java 8 Interview Questions||Computer Programming Interview Questions|
|Basic C Interview Questions||Java Hadoop Developer Interview Questions|
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.