How to Write Test case in Cypress - Bug Reaper

                  Bug Reaper

Lean about Automation Testing,Selenium WebDriver,RestAssured,Appium,Jenkins,JAVA,API Automation,TestNG,Maven, Rest API, SOAP API,Linux,Maven,Security Testing,Interview Questions

Thursday, 16 July 2020

How to Write Test case in Cypress

Cypress test consists of
describe(): It is is simply a way to group our tests. It takes two arguments, the first is the name of the test group, and the second is a callback function. 

it(): We use it for an individual test case. It takes two arguments, a string explaining what the test should do, and a callback function which contains our actual test.

Test Case-->We will Open the page in different view ports

View ports can be found in 


First Test case

/// <reference types="cypress" />

context('Window', () => {
  beforeEach(() => {
    cy.visit('https://bugreaper.blogspot.com')
  })

  it('open in Mac 15', () => {
    // https://on.cypress.io/window
    cy.viewport('macbook-15')
    cy.screenshot()
    cy.wait(200)
  })

   it('open in Mac 13', () => {
    // https://on.cypress.io/window
    cy.viewport('macbook-13')
    cy.screenshot()
    cy.wait(200)
  })

    it('open in ipad-2', () => {
    // https://on.cypress.io/window
    cy.viewport('ipad-2')
    cy.screenshot()
    cy.wait(200)
  })
    
it('open in samsung-s10', () => {
    // https://on.cypress.io/window
    cy.viewport('samsung-s10')
    cy.screenshot()
    cy.wait(200)
  })
    
  
})

Now when you run this In cypress, after successfull run a Screenshot folder would be created and will have all screenshots











2 comments: