Tutorials Hut

  • Cypress tutorials




  • Run Test Case in Cypress

    In this tutorial we will see how to start test case execution or run test case in cypress.Below topics will be covered :

    RunTest Case in Cypress

    Executing test case from test runner

    Steps:

      1. Write the test cases in the cypress and save it.2.
      2. In the terminal open cypress using “node_modules\.bin\cypress open”.
      3. From the Test runner view , all the test cases are displayed.
      4. If you want to select any specific browser then change the browser from the top right corner of the test runner.
    run cypress test from test runner

    5. Simply click on the test case and execution will start.
    6. Execution will begin. Browser opens

    Cypress test case execution

    Execute test case from command line

      • Command to execute the test case from the command line is “cypress run”.
      • It will automatically execute all the test cases present under the Integration folder.

    To run one particular test case use

    “Cypress run –spec “path to the test case”

    Eg: Cypress run –spec “cypress/integration/myfirsttc.js”

    Cypress run single spec file
      • No browser opens . test is executing in headed mode and in Electron browser
    Cypress test case execution in headed mode
    • When executing using the command line the execution is head less that means the test will execute but the browser is not displayed on the UI.
    • By default it executes in the Electron browser.

    Run Cypress Test case in Headed mode from Command Line

    • If you want to execute in headed mode in default  browser from command line use:

    “Cypress run — headed”

    Cypress test in headed mode default command
    • Test case is executed in the default electron browser.

    Run Cypress Test case in Headless mode and some other browser from Command Line

    • If you want to execute in any other browser and choose the browser from command line use:

    “Cypress run — browser chrome”

    headless mode and select browser cypress command line
    • It will run headless in the chrome browser.

    Execute Cypress Test case in Headed mode and some other browser from Command Line

    • Test will run in headed mode and user defined browser.
    headed mode and select browser cypress command line
    About Author

















  • Leave a Reply

    Your email address will not be published. Required fields are marked *