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
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.
POST /api/v1/executions |
---|
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
type | String | Yes | Specify execution type. for cypress use Cypress |
project | File | Yes | The Cypress project to run. |
conf | JSON String | No | A configuration file for the requested execution. |
Cypress configuration
In order to run Cypress project, a configuration must be supplied.
There are 2 options to add configuration:
- add the conf parameter as a JSON string to the POST request.
- 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 |
---|---|---|---|
browsers | List | Yes | A list of browser names and cypress versions to run the project on. each entry in the list is as follows: { "browser": "browser name" "cypressVersion": "cypress image version" } Supported browsers are Chrome, Firefox and Electron |
runTags | Map | No | 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" } |
exclude | List | No | A list of test names to exclude from the project while running, for example: "exclude": [ "actions.spec.js", "badTest.spec.js" ] |
npm_dependencies | List | No | A list of npm dependencies that needs to be installed before running the project, for example: "npm_dependencies": [ "npm-package1", "npm-package2", ... ] |
runConfFile | String | No | A configuration file to run the project with. Must be located in the root directory. "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 |
---|
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 |
---|
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.