Cypress Configuration

The first time you open Cypress Test Runner, it creates the cypress.json configuration file. This JSON file is used to store any configuration values you supply.

Initially it is empty, if you want to add some configuration visit here. Once you will visit Cypress website for configuration you will find different tables, first one is Global which contain basic configuration like baseURL, env, port etc.

If you will scroll down you will find different options like Timeout, Folders/Files,  Screenshots, Videos, Downloads, Browsers and few others.

We don't need to use all the configuration at once, we can add them when we need it. Let's do the basic configuration for our project and test it.

{
    "baseUrl":"https://autopract.com",
    "ignoreTestFiles":"**/examples/*",
    "viewportHeight":768,
    "viewportWidth":1024,
    "defaultCommandTimeout": 10000,
    "execTimeout": 60000,
    "pageLoadTimeout": 60000,
    "requestTimeout": 60000,
    "responseTimeout": 60000, 
    "video":false	
}

Now here, I have specified

  • baseUrl: base url of my website
  • ignoreTestFiles: ignore example folder if you don't want to executed test in example folder
  •  viewportHeight and viewportWidth: set viewport Height and Width to standard size.
  • defaultCommandTimeout: Time, in milliseconds, to wait until most DOM based commands are considered timed out
  • execTimeout: Time, in milliseconds, to wait for a system command to finish executing during a cy.exec() command
  • pageLoadTimeout: Time, in milliseconds, to wait for page transition events or cy.visit(), cy.go(), cy.reload() commands to fire their page load events.
  • requestTimeout: Time, in milliseconds, to wait for a request to go out in a cy.wait() command
  • responseTimeout:  Time, in milliseconds, to wait until a response in a few commands
  • video: To Capture video or not

You can create file inside integration folder with any name of your choice and extension .spec.js for example myFirstTest.spec.js.

You can type below command to test configuration:

$ npx cypress open

It will open below window:

Cypress Configuration

Sat, 05/01/2021 - 20:21

Authored by

Tarun Goswami, works as a Technical Lead at the well-known IT services company. With Over 11+ years of experience in Quality Assurance, he writes engaging and informative blogs in his spare time.

Video Tutorial: Cypress Configuration File

Tags