Wednesday, August 4, 2021

How to Install Node.js, VS Code Editor and Cypress in Linux?

 Node.js Installation: 

There are different ways to install Node.js in Linux machine. Here, I will describe how to install Node.js via binary archive in ubuntu pc. The installation process is described step by step below.

1. Go to the Node.js website and click the link to download Node.js for Linux Binaries (x64).

2. Create a new folder and keep the downloaded file into it. I have downloaded file Node.js node-v14.17.4-linux-x64.tar.xz

3. Open terminal and create nodejs folder using Linux command as follows

sudo mkdir -p usr/local/lib/nodejs







4. Unzip the downloaded file and copy the file to the directory /usr/local/lib/nodejs and install using following command.

sudo tar -xJvf node-v14.17.4-linux-x64.tar.xz -c /usr/local/lib/nodejs






5. To set the environment variable open profile file using following command from terminal.

sudo nano ~/.profile






6. Write the following code into the profile file and save the file.

# Nodejs

VERSION=v14.17.4

DISTRO=linux-x64

export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH











7. Node.js has been successfully installed and configured. To refresh profile use the following command from terminal.

. ~/.profile






8. Check Node.js version using following command from terminal.

$ node -v

Node.js version will show in terminal v14.17.4






9. Check npm version using following command from terminal.  

$ npx -v

npm version will show in terminal 6.14.14






To check normal output use the following command from terminal.

$ npm version 

Normal output of npm version is as follows.

➜  node -v

v14.17.4

➜  npm version

{ npm: '6.14.14',

 ares: '1.17.1',

brotli: '1.0.9',

 cldr: '39.0',

 llhttp: '2.1.3',

 icu: '69.1',

 modules: '83',

 napi: '8',

 nghttp2: '1.42.0',

 node: '14.17.4',

 openssl: '1.1.1k',

 tz: '2021a',

 unicode: '13.0',

 uv: '1.41.0',

 v8: '8.4.371.23-node.76',

 zlib: '1.2.11' } 














VS Code Editor Installation:


VS Code means Visual Studio Code is an smart editor for java script coding. Here, I will describe how to download VS Code and its installation process step by step in Linux machine.

1. Go to the VS Code website and download vs code  

2. Create a new folder and keep the downloaded file into it. I have downloaded .deb file code_1.58.2-1626302803_amd64.deb 

3. To install the downloaded file, open terminal from folder path and type Linux command as follows.
sudo dpkg -i code_1.58.2-1626302803_amd64.deb








4. Visual Studio Code has been successfully installed. To open Visual Studio Code editor, use following command from terminal.
$ code








5. Visual Studio Code editor will be opened as follow.








Cypress Installation:


Cypress uses only javascript language and mocha framework by default. It differs from Selenium. So to install cypress I will use vs code editor that supports javascript code with libraries that required for cypress. I have used the link cypress installation that helped me to install cypress. Here, I will describe step by step how to install cypress.

1. Create a new folder in local machine, I have created a folder named CypressPractice.
2. Open visual studio code editor, go to File -> Add Folder To Workspace and add the folder to visual studio code editor. Folder is added to visual studio code editor as follows.


 











3. Right click on CypressPractice folder from editor and Open in Terminal as follows.














4. As folder is empty initially, so use the following command from terminal to initialize npm.
init npm















5. Enter package name, version, description, entry point, test command, git repository, keywords, author, license if any of these required and select as per need. Press ENTER and see package.json file will be created under CypressPractice folder as follows.















6. Clear terminal and write the following command to install cypress.
npm install cypress --save-dev















7. After installation cypress, check node_modules and package-lock.json both are created under CypressPractice folder as follows.















8. To check cypress version use the following command from terminal.
./node_modules/.bin/cypress version


















9. To open cypress use the following command from terminal.
./node_modules/.bin/cypress open















10. Cypress interface will be visible as follows.












11. Click any item under example folder of Integration directory and see the existing script will be run inside the browser as follows.















12. To open cypress using npm run command, need to configure into package.json file as follows.
  "scripts": {
    "cypress:open": "cypress open"
  }















13. After using the npm run cypress:open command cypress will be run as follows.
















That's all about installation of node.js, vs code editor and cypress. I hope this article will be helpful for Linux user.  Thanks all.













Sunday, August 1, 2021

What is Cypress and its Architecture?

What is Cypress?

Cypress is an open source and front end testing tool for modern web applications. Its execution is very fast compared to other tool. Basically cypress is used to overcome the hurdles of React and AngularJS based applications testing. Both developers and QA automation engineers can use cypress. Developers use it for Unit and integration level testing as well as QA guys use it for functional end to end testing. Cypress is a faster, effortless and dependable tool for testing any applications that run on browsers.

Cypress Architecture or How it works?

In this architecture, Cypress runs inside the browser. Node.js server that is running on operating system. Cypress makes a connection with browser through the proxy. Cypress test is running on browser and application is also there in. Cypress starts with the proxy and makes connection via web socket. Through the proxy cypress gets the HTTP request from application inside the browser, ensures which tests need to execute and finally cypress sends the HTTP response via proxy to the browser.







Figure-1: Cypress Simple Architecture