Transcripted Summary

Hey, hello everyone.

In this video, we will see: what is Mocha? And how to install it.

Mocha is a JavaScript-based testing framework running on NodeJS and browser.

This is like the TestNG framework for Java, and NUnit framework for C#, if you have used those two languages earlier.

It is used to organize the tests and execute them in a logical sequence to make the testing more effective. It also makes the asynchronous testing to be simple and fun to execute.

Now, let's install the prerequisites to continue our course.

We will first install several prerequisites like NodeJS and Node Package Manager, which is nothing but NPM, and then install Mocha.

# Installing NodeJS and Node Package Manager

To install NodeJS, first launch NodeJS official website and then navigate to downloads link.

In the downloads link, if you see, the NodeJS version of 10.15.3 is available as long-term support version, and it includes the Node Package Manager version 6.4.1 as well.

Just select the installer according to your operating system. The operating system which I'm working on is macOS, and hence I'm selecting the 64-bit installer.pkg file.

Once this is downloaded, launch the installer.

If you see on the installer, you will be able to see that this particular installer can install NodeJS and the Node Package Manager as well.

The installation is pretty straightforward, and hence you can click Continue, and you can agree with the license, and then click Continue again. Then click on the Destination, and then Install.

Once it is installed successfully, you will be getting this particular message [“The installation was completed successfully” with details of files], and Close this.

Now, let's see whether the NodeJS and the Node Package Manager is installed successfully.

To do that, I will launch my terminal.

So, my terminal is launched. All I'm going to do is first check whether the NodeJS is installed successfully.

To do that, all I need to do is type

node -v

which eventually tells me the version of Node. Just like what we have seen in the official website.

And let's see whether we have installed the NPM as well by giving this command

npm -v

And yes, we have installed it successfully.

Now let's install Mocha.

# Installing Mocha

To install Mocha, all I need to do is go to the official website of Node Package Manager and search for Mocha package.

So, when I search it, the first link takes me to the official Mocha package.

You will be able to see there are 23 dependencies for Mocha. And there are 151 versions available for Mocha.

But the latest version, which we are going to install, is 6.1.4 [latest version as of the time of this recording].

To install this, I'm going to launch my terminal again and type in this command

npm install mocha -g

I want this package to be installed as a global package, and hence I'm amending this command with “-g”.

And hit Enter.

So currently, it is downloading all the dependency packages for Mocha, and extracts, and installs.

Now that it has installed successfully, let's see whether Mocha is installed.

To verify that, all I'm going to do is type this command of

mocha -version

and hit Enter.

And yes, Mocha has installed successfully.

Thank you so much for watching this video.


© 2022 Applitools. All rights reserved. Terms and Conditions Privacy Policy GDPR