![JasmineJS Tutorial](/jasminejs/images/jasmine-js-mini-logo.jpg)
- JasmineJS Tutorial
- JasmineJS - Home
- JasmineJS - Overview
- JasmineJS - Environment Setup
- JasmineJS - Writing Text & Execution
- JasmineJS - BDD Architecture
- JasmineJS - Building Blocks of Test
- JasmineJS - Matchers
- JasmineJS - Skip Block
- JasmineJS - Equality Check
- JasmineJS - Boolean Check
- JasmineJS - Sequential Check
- JasmineJS - Null Check
- JasmineJS - Inequality Check
- JasmineJS - Not a Number Check
- JasmineJS - Exception Check
- JasmineJS - beforeEach()
- JasmineJS - afterEach()
- JasmineJS - Spies
- JasmineJS Useful Resources
- JasmineJS - Quick Guide
- JasmineJS - Useful Resources
- JasmineJS - Discussion
JasmineJS - Not a Number Check
Jasmine provides a special matcher to check this special type of testing scenario that is toBeNaN().
Let us modify our customerMatcher.js with the following code.
describe("Different Methods of Expect Block",function () { it("Example of toBeNaN()", function () { expect(0 / 0).toBeNaN(); }); });
Here we want to test what is the value of “0/0” which cannot be determined. Hence, this piece of code will generate the following green screenshot.
![toBeNan](/jasminejs/images/tobenan.jpg)
Now let us again modify the code with the following logic, where we will assign one variable exp to 25 and expect the result is not a number one dividing it with 5.
describe("Different Methods of Expect Block",function () { var exp = 25; it("Example of toBeNaN()", function () { expect(exp/5).toBeNaN(); }); });
This piece of code will yield the following output.
![toBeNan Output](/jasminejs/images/tobenan_output.jpg)
Advertisements
To Continue Learning Please Login