Last active
January 15, 2022 03:22
-
-
Save rakibulinux/1bc61f0d652d5cc0260a416ef997b85b to your computer and use it in GitHub Desktop.
How to install Cypress on Linux Operating System
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#Required dependencies installed on your system | |
sudo apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb | |
#Install NodeJS and Yarn | |
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - | |
sudo apt-get install -y nodejs | |
sudo apt-get install gcc g++ make -y | |
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - | |
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list | |
sudo apt-get update && sudo apt-get install yarn -y | |
#Cypress Installation Steps: | |
# Select a path where Cypress will be installed | |
mkdir cypress | |
cd /project/path | |
or | |
cd cypress | |
#Or clone this project: | |
git clone https://github.com/ether/etherpad-lite.git | |
cd etherpad-lite | |
# Run this command. This will install Cypress locally as a dev dependency for your project | |
npm install cypress --save-dev | |
#Note: Make sure that you have already run npm init or have a node_modules folder or package.json file in the root of your project to ensure cypress is installed in the correct directory. | |
#How to run Cypress scripts: If Cypress has now been installed to your ./node_modules directory, with its binary executable accessible from ./node_modules/.bin | |
./node_modules/.bin/cypress open | |
OR | |
#Run shortcut using npm bin | |
$(npm bin)/cypress open | |
OR | |
#This command is much easier and clearer to add Cypress commands to the scripts field in your package.json file ** | |
npm run cypress:open | |
#Sample Cypress Script: Filename of the automated script: facebook_login.js | |
describe('Login to Facebook', function() { | |
// ---- Login to Facebook ---- // | |
it('login successful', function() { | |
cy.visit('https://www.facebook.com/') | |
cy.get('input[name="email"]').type('test@example.com') | |
cy.get('input[name="pass"]').type('test_pass') | |
cy.get('label[id="loginbutton"]').click({ multiple: true, force: true}) | |
cy.wait(4000) | |
}); | |
}); | |
#Adding npm scripts: While there’s nothing wrong with writing out the full path to the Cypress executable each time, it’s much easier and clearer to add Cypress commands to the scripts field in your package.json file. | |
{ | |
"scripts": { | |
"cypress:open": "cypress open" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment