
- Node.js - Home
- Node.js - Introduction
- Node.js - Environment Setup
- Node.js - First Application
- Node.js - REPL Terminal
- Node.js - Command Line Options
- Node.js - Package Manager (NPM)
- Node.js - Callbacks Concept
- Node.js - Upload Files
- Node.js - Send an Email
- Node.js - Events
- Node.js - Event Loop
- Node.js - Event Emitter
- Node.js - Debugger
- Node.js - Global Objects
- Node.js - Console
- Node.js - Process
- Node.js - Scaling Application
- Node.js - Packaging
- Node.js - Express Framework
- Node.js - RESTFul API
- Node.js - Buffers
- Node.js - Streams
- Node.js - File System
- Node.js MySQL
- Node.js - MySQL Get Started
- Node.js - MySQL Create Database
- Node.js - MySQL Create Table
- Node.js - MySQL Insert Into
- Node.js - MySQL Select From
- Node.js - MySQL Where
- Node.js - MySQL Order By
- Node.js - MySQL Delete
- Node.js - MySQL Update
- Node.js - MySQL Join
- Node.js MongoDB
- Node.js - MongoDB Get Started
- Node.js - MongoDB Create Database
- Node.js - MongoDB Create Collection
- Node.js - MongoDB Insert
- Node.js - MongoDB Find
- Node.js - MongoDB Query
- Node.js - MongoDB Sort
- Node.js - MongoDB Delete
- Node.js - MongoDB Update
- Node.js - MongoDB Limit
- Node.js - MongoDB Join
- Node.js Modules
- Node.js - Modules
- Node.js - Built-in Modules
- Node.js - Utility Modules
- Node.js - Web Module
Node.js - Assert Module
Assert module in Node.js provides a collection of assertion functions that are used in verifying invariants. If the condition is evaluated to false, or 0, an assertion error will be returned, and the program is terminated. If it is evaluated to true, nothing is returned to the output.
Installation
This installation is optional because assert is an inbuilt Node.js module.
Open the command prompt and navigate to your working folder (to the folder where you saved your file.js).
Now type the command which is in the snippet below. With this, you can install the assert module package.
npm install assert
Now, you are free to use all the functions available in the assert module.
After installation is done, you can check the version of the assert module by using the command which is in the below snippet.
npm version assert
List of Functions
Following is a list of functions available in the Assert Class −
Sr.No | Function & Description |
---|---|
1 |
Used to check, if the value is truthy |
2 |
Used to test for equality between the input parameters. |
3 |
Used to "deep" test for equality between the input parameters. |
4 |
It will expect the input string not to match the regular expression. |
5 |
Used to get the endianness of the CPU. |
6 |
Used to assert that a function or expression does not throw an error when it is executed. |
7 |
Used to test for equality between the input parameters. |
8 |
It will throw an assertion error with the given error message. |
9 |
It will throw assertion error, if the value passed is undefined or null. |
10 |
Used to test for deep inequality. |
11 |
Used to test for deep "strict" inequality. |
12 |
Used to test inequality between the input parameters. |
13 |
Used to test "strict" inequality between the input parameters. |
14 |
Used to test if the input value is truthy. |
15 |
Used to return the total amount of system memory as a number of bytes. |
16 |
Used to check if two values are equal. |
17 |
It will except the input function to throw an error. |
Class: CallTracker Functions
These functions are currently experimental and behavior might still change.
Sr.No | Function & Description |
---|---|
1 |
Used to create a new CallTracker object, that can be used to track if functions were called a specific number of times. |
2 |
Used to get the information about expected and actual number of calls of the functions that have not been called the expected number of times. |
3 |
Used to verify how many times function was actually called compared to expected number of calls. |