Cypress -Grouping Tests

Cypress -Grouping Test scenario's or Test suite

   We used to maintain and Execute Smoke test, functional test and Regression Test. In Cypress we can be able to achieve with title or Tags to execute specific test cases and test suite using grep plugin.

Step 1:  Need to Install grep for grouping test cases

     Terminal : npm i -D cypress-grep 

Step 2: Verify package.json file

                    

 
Step 3: Go to  "cypress\support\index.js"

      //import
                  require('cypress-grep')()

                  


 Step 4: Go to  "cypress/plugins/index.js"

    Add Required module:
     module.exports = (on, config) => {
     // optional: register cypress-grep plugin code
     // https://github.com/cypress-io/cypress-grep
     require('cypress-grep/src/plugin')(config)
     // make sure to return the config object
     // as it might have been modified by the plugin
     return config
     }
                

    Step 4: Sample test suite with different types tests

Step 5: Group Run by using grep title

#run only the tests with "smoke" in the title

npx Cypress run npx cypress run --headless --browser chrome --spec cypress\integration\Group\* --env grep="Smoke"

#run only the tests with "smoke; Functional" in the title

npx Cypress run npx cypress run --headless --browser chrome --spec cypress\integration\Group\* --env grep="Smoke;Functional"


Step 6: Group Run by using grep tags

# run tests tagged @smoke or @Functional

 npx Cypress run npx cypress run --headless --browser chrome --spec cypress\integration\Group\* --env grepTags="Smoke Functional"


# run tests tagged @smoke and @Functional

npx Cypress run npx cypress run --headless --browser chrome --spec cypress\integration\Group\* --env grepTags="Smoke+Functional"



# run tests untagged @-Functional

npx Cypress run npx cypress run --headless --browser chrome --spec cypress\integration\Group\* --env grepTags="-Functional"


No comments:

Post a Comment

Lets Start...............

Cypress

Syllabus Q & A Set -1 Q & A Set -2