
- 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
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.

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.

Advertisements