Last updated: Feb 22, 2021 14:18
Prerequisites
The integration require that the following be installed:
Network prerequisites
If you connect via VPN, for smooth Cypress execution, make sure the following URLs are accessible from your network:
<your-cloud>.app.perfectomobile.com
<your-cloud>.perfectomobile.com/lab-execution
Access to the npm registry or any other custom registry you use
If these URLs are not accessible, Cypress execution may be limited in that executions will run, but Cypress will not run and no tests will be executed or shown in the SDK.
Proxy configuration
If you need to work behind a proxy when using the Perfecto-Cypress SDK, configure the following environment variable on your workstation: https_proxy
1 | Install Cypress
- Launch a terminal in your IDE.
- In the workspace folder, create a new folder, for example CypressSEDemo.
- Change to the new folder you created.
Run the following command to create the
package.json
file:npm init
To install Cypress, run the following command from the command line:
npm install cypress --save-dev
--save-dev
saves it as a dependency in thepackage.json
file.To launch Cypress, run the following command:
npx cypress open
This launches the Cypress UI and also creates a
cypress
folder inside the new folder you created in step 1.- In the Cypress UI:
- Click any
*.spec.js
file and launch it in the selected browser. - Close the Cypress UI.
- Click any
2 | Install the Perfecto-Cypress SDK
Return to the workspace folder 'CypressSEDemo' by running the following command:
cd ..
Install the Perfecto-Cypress SDK by running the following command:
npm install perfecto-cypress-sdk --save-dev
To add Perfecto Cypress Reporter capabilities, run the following command:
npm install perfecto-cypress-reporter --save-dev
3 | Initialize the Perfecto-Cypress SDK
Create the configuration files. 3 configuration files are required to run Cypress tests in Perfecto.
npx perfecto-cypress init --tests.path=./CypressSEDemo/
Running the
init
command generates the following configuration files for you (if they do not exist):perfecto-config.json
: See Perfecto config options.tests-folder/cypress.json
: See the Cypress documentation.tests-folder/package.json
: All dependencies that your project needs to execute theCypress run
command.
- In the
perfecto-config.json
file, define the following:- The cloud name, for example
demo
. The SDK automatically adds.perfectomobile.com
. - The security token, either hard-coded or passed later as a parameter in the command line.
- The test specs you want to execute in the cloud, for example
**/*.specs.js
for thespecsExt
parameter
- The cloud name, for example
In the
package.json
file, specify one of the following Cypress versions. Otherwise, the execution takes an additional 4 minutes.- 3.8.3
- 4.12.1
- 5.6.0
- 6.0.1
Import perfecto-cypress-reporter into the support file
cypress/support/index.js
by adding the following code:import 'perfecto-cypress-reporter'; // or require('perfecto-cypress-reporter');
Use the following SDK commands as needed:
run
,pack
,upload
For more information on these commands, run the--help
command.
4 | Execute Cypress test specs
For a quick execution, perform the following steps:
Run the command from terminal, as follows:
npx perfecto-cypress run --config=.\CypressSEDemo\perfecto-config.json
where
CypressSEDemo
is the name of the folder you created.- Launch Perfecto and go to Test Analysis > Live Stream to view the live execution. When it is done, you can see the results based on the CI Job or Project, or you can open the report link that should appear in the command line window.
Following is a complete list of command line parameters, including the known reporting perfecto-cypress-sdk options to be passed.
When uploading a Cypress test suite to the Perfecto cloud, utilize the following command options:
After uploading a .zip
file to the cloud, the cloud admin should obtain the repository ID of that .zip
file and pass it through the run
command to be executed in the cloud. For example, if the repository ID is PRIVATE:perfecto-cypress.zip
, the command would be as follows:
npx perfecto-cypress run --config=.\test\perfecto-config.json --ta=PRIVATE:perfecto-cypress.zip
Perfecto-config.json details
Option | Example | Description | Required |
---|---|---|---|
credentials | { | Specifies the credentials used to initiate the communication with Perfecto services. | Can also be provided as a CLI parameter. |
capabilities | [ | Specifies the required capabilities. For more information about available capabilities, see Define capabilities. For each configuration, you also need to add the Perfecto Connect tunnelId value. For example: { "deviceType": "Web", "platformName": "Windows", "platformVersion": "10", "browserName": "Chrome", "browserVersion": "latest", "resolution": "1024x768", "location": "US East", "tunnelId": "6d82110a-7cbe-4916-8428-ab4260d29382" }, For more information, see Associate a device with a Perfecto Connect tunnel. | Required |
tests.path | "./tests" | Specifies the path to the
This is also the folder that the SDK packs and uploads to the Perfecto cloud. | Can be provided also as a CLI parameter. |
tests.ignore | [ | Specifies a list of patterns to exclude from the tests' zip archive. | Optional |
tests.specsExt | "**/*.cy.js" | Specifies a pattern to guide the SDK which test specs to run. | Can be provided also as a CLI parameter |
nodeVersion | "12" | Specifies the major Node.js version for the Cypress execution environment. Supported values: | Optional |
framework | "CYPRESS" | Required | |
env | { | Specifies the environment variables that your Cypress tests need. | Optional |
reporting | { | Specifies information for Perfecto Smart Reporting. For more information, see Smart Reporting capabilities. | Optional |
scriptName | "My Cypress project" | The name used as the Report Name for the Report Library and Live Stream interfaces. See also Smart Reporting capabilities. | optional |