Install the plugin by running:
$ npm install --save-dev cypress-cucumber-preprocessor
Running Cucumber feature file with TAGS like @Smoke & @Regression:
$ npx cypress-tags run -e TAGS="@Smoke" --headed --browser chrome
Install the plugin by running:
$ npm install --save-dev cypress-cucumber-preprocessor
Running Cucumber feature file with TAGS like @Smoke & @Regression:
$ npx cypress-tags run -e TAGS="@Smoke" --headed --browser chrome
$ npm -i init : to create package.json file
$ node_modules/.bin/cypress open : to open the test runner
Cypress run commands:- can use either of the below 4 commands
$(npm bin)/cypress run
./node_modules/.bin/cypress run
npx cypress run
yarn cypress run
Cypress run commands for 1 test case:-
$ npm run cy:run -- --record -- spec "cypress/integration/myspec.js"
by default all test cases from cmd line runs in headless mode. if needed to run in browser? need to mention --headed in the end of cmd.
./node_modules/.bin/cypress run --headed
$ npm -i init : to create package.json file
if we need to run spec's in specific browser we can specify that in cmd.
$ ./node_module/.bin/cypress run --browser chrome
$ ./node_module/.bin/cypress run --browser edge
Cypress framework folder structure:
fixture: for storing data in json or excel files.
Integration: for writing test spec's
Plugins: for setting browser settings like full screen, to handel cypress listeners events.
Support: customize cmds, reusable methods, basically used to build POM
Videos: it stores the latest execution proofs of test specs
CMD to install mocha:-
$ npm install --save-dev mocha
CMD to install mochawesome reports:-
$ npm install --save-dev mochawesome
CMD to install IFrame in Cypress:
npm install -D cypress-iframe
CMD to override the execution url from terminal:-
$ ./node_module/.bin/cypress run --spec cypress/integration/UI/TestFramework1.js --env url=https://rahulshettyacademy.com/angularpractice/shop --headed
CMD to run scripts and have results in dashboard:-
npx cypress run --record --key <"your respective project key from dashboard">
Connect VM machine
Connect through SSH
Jenkins installation:-
$> sudo apt-get update.
$> sudo apt install openjdk-8-jdk (OR) sudo apt install default-jdk
$> wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
wget --no-check-certificate -qO - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
$> sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
/etc/apt/sources.list.d/jenkins.list'
$> sudo apt-get update
$> sudo apt-get install jenkins
sudo su - ubuntu
sudo apt-get update
Working Directory:-
Staging Area:-
Commit:-
Github:-
Master branch & Feature Branch.
git setup in GCP, Ubuntu instance:-
GIT DIFF:- To find difference between two versions of the file.
git diff <commit id>
MERGING BRANCHES:-
Git Merge:
git merge <source branch name/feature branch name> run this cmd from the master branch.
Git Rebase:
It's more used to get the latest master branch code to feature branch, once after the feature branch code is tested and merged into master branch. it helps the feature branch to rebase the latest code from master.
1. "git checkout <featurebranch name>" 2. "git rebase master"
1. To Run Single test :
npx cypress open --config testFiles="/Users/rajeshvarma/Documents/CypressProj/cypress/integration/UIScripts/tc1.spec.js" ---------------------------------------------------------------------------------------------------------------------------
2. To run cypress multiple test cases option:
npx cypress open
---------------------------------------------------------------------------------------------------------------------------
3. crossbrowser testing:-
$ npx cypress run --browser chrome --spec “cypress/integration/examples/tests/e2e_test.spec.js”
update package.json file with below entries for crossbrowser:
"scripts": { |
"cy:run:chrome": "cypress run --browser chrome", |
"cy:run:firefox": "cypress run --browser firefox" |
}
---------------------------------------------------------------------------------------------------------------------------
4. Cypress reporting:-
$ npm install mochawesome. OR. $ npm install junit
update cypress.json file with below entries :-
{ |
"reporter": "mochawesome", |
"reporterOptions": |
{ |
"reportDir": "cypress/results", |
"overwrite": false, |
"html": true, |
"json": true |
} |
}
$ npx cypress run --reporter mochawesome --spec “cypress/integration/examples/tests/e2e_test.spec.js”
Cypress.json config file for JUnit:--
{ |
"reporter": "junit", |
"reporterOptions": |
{ |
"reportDir": "cypress/results", |
"mochaFile": "results/my-test-output.xml", |
"toConsole": true |
} |
}
$ npx cypress run --reporter junit \ --reporter-options “mochaFile=results/my-test-output.xml,toConsole=true”
---------------------------------------------------------------------------------------------------------------------------