26.10.22

Cypress.io Imp CMD's

$ 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">


No comments:

Post a Comment