Page tree
Skip to end of metadata
Go to start of metadata

Cypress is a front-end testing tool for web applications using modern JavaScript frameworks.

Cypress enables you to write all types of tests:

  • End-to-end tests
  • Integration tests
  • Unit tests

And can test anything that runs on a browser.

Article contents:

Requirements

Cypress Support is available only in SaaS clouds.

In order to run Cypress projects in Cloud, you need to have a Docker Swarm and Execution Service set up in your environment.

Cypress projects are run inside containers in Docker Swarm via Execution Service API.

In order to run Cypress project Cloud need to have Browser license.

Execution Service API

The role of the user performing the Rest Operation is specified by the Authorization header.

For more information please visit How To Execute Rest API, for a detailed example.

Start a Cypress execution

Enables users to run Cypress projects.
Cypress projects are run asynchronously, the response received is immediate.
Our Cypress support includes version 10.

POST /api/v1/executions


Parameters

Name

Type

Mandatory

Description

typeStringYes

Specify execution type. for cypress use Cypress

projectFileYes

The Cypress project to run.
Compress the entire Cypress project and select the .zip file.
A valid project contains a cypress.json file in the root directory

confJSON StringNo

A configuration file for the requested execution.
Please read the next section for more information about the configuration.

POST Cypress Execution Response
{
    "status": "SUCCESS",
    "data": {
        "Test Run Id": "3520546",
        "Link to Reporter": "https://CLOUD_SERVER/reporter/#/test-view-view/-1?testView={%22byKey%22:%22test.run.id%22,%22byKeyValue%22:%223520546%22}"
    },
    "code": "OK"
}


Cypress configuration

In order to run Cypress project, a configuration must be supplied.
There are 2 options to add configuration:

  1. add the conf parameter as a JSON string to the POST request.
  2. a file named digitalai.json with the required configuration in the root directory of the project

When supplying both options, the digitalai.json is ignored

Configuration parameters:

Name

Type

Mandatory

Description

browsersListYes

A list of browser names and cypress versions to run the project on. each entry in the list is as follows:

{
	"browser": "browser name"
	"imageVersion": "cypress image version"
}

Supported browsers are Chrome, Firefox and Electron

runTagsMapNo

A map of tags and their values to add to the report of each test in the project, for example:

{
	"tag 1": "tag 1 value"
	"tag 2": "tag 2 value"
}
excludeListNo

A list of test names to exclude from the project while running, for example:

"exclude":
[
	"actions.spec.js",
	"badTest.spec.js"
]
npm_dependenciesListNo

A list of npm dependencies that needs to be installed before running the project, for example:

"npm_dependencies":
[
	"npm-package1",
	"npm-package2",
	...
]
runConfFileStringNo

A configuration file to run the project with. Must be located in the root directory. 

"myConfigFile.json"
Cypress configuration example
{
  "browsers": [{
      "browser": "chrome",
      "imageVersion": "8.3.0"
    },
    {
      "browser": "chrome",
      "imageVersion": "8.2.0"
    },
    {
      "browser": "firefox",
      "imageVersion": "8.2.0"
    },
    {
      "browser": "electron",
      "imageVersion": "8.1.0"
    }
  ],
  "runTags": {
	"tag 1" : "tag 1 value",
	"tag 2" : "tag 2 value",
	"tag 3" : "tag 3 value"
  },
  "exclude": [
	"actions.spec.js",
	"badTest.spec.js"
  ],
  "npm_dependencies": [
	"npm-package1",
	"npm-package2"
  ],
  "runConfFile": "myConfigFile.json"
}

Get Cypress execution status

Get the Cypress execution status

Get status privileges:

  • User can get only his own session status
  • Project admin can get his own session status and can get statuses from other users of his project
  • Admin can get any session status on his cloud
GET  /api/v1/executions/{Execution_ID}/status
Get Cypress Execution Response
{
    "code": "OK",
    "data": {
        "Test Run Id": "3023f8be-783e-4b70-b830-3ca2e4bd3f7a",
        "Test Run State": "RUNNING",
        "Number of requested browsers": "2",
        "Number of browsers completed": "0",
        "Number of browsers running": "2",
        "Number of browsers in queue": "0",
        "Link to Reporter": "https://CLOUD_SERVER/reporter/reporter/dashboard/#/test-view-view/-1?testView=%7B%22byKey%22:%22test.run.id%22,%22byKeyValue%22:%223023f8be-783e-4b70-b830-3ca2e4bd3f7a%22%7D"
    },
    "status": "SUCCESS"
}

Cancel Cypress execution

Cancel Cypress execution project by test run id.

Cancel privileges:

  • User can cancel only his own execution
  • Project admin can cancel his own execution and can cancel executions from other users of his project
  • Admin can cancel any execution on his cloud
PUT  /api/v1/executions/{executionId}/actions/cancel
Response if session canceled successfully
Execution session id - <session id> canceled
Response if user has no privileges to cancel the session
{
	"status": "ERROR",
    "data": {
        "User": "Security Error"
    },
 	"code": "FORBIDDEN"
    
}

Get Cypress execution logs

Get the logs of a certain Cypress run.

Get logs privileges:

  • User can get only his own session logs
  • Project admin can get his own session logs and can get logs from other users of his project
  • Admin can get any session logs on his cloud
GET  /api/v1/executions/{Execution_ID}/logs

Returned response is a zip file with the logs or an error message if any error occurred.

  • No labels