Introduction
Getting started with Cypress
Cypress is one of the most popular end-to-end and integration test frameworks out there. Learn how you can easily use Cypress with Testkit.
Installation
If you haven't already, make sure you have the latest version of the Testkit CLI installed:
npm install --global @testkit-labs/cli@latest
Configuration
You have two options to configure the Testkit Cypress runner
Using the CLI (recommended)
Using the CLI is the easiest and most straight forward configuration option. This will ask you a few questions and then create a testkit.json file in the current working directory.
testkit cypress init
Manually creating the testkit.json file
Create a file named testkit.json in the root of your project, on the same level as your package.json file. Here is an example configuration:
{
"org": "<Your Organization ID>",
"parallel": 1,
"browsers": ["chrome"],
"additional-dependencies": [],
"cypressFolder": "cypress",
"cypressConfig": "cypress.{config.{js,ts},json}",
"specFiles": "cypress/integrations/**/*.{spec|test|e2e|integration}.{js,ts}"
}
Options
org(required): The organization ID of your Testkit account.parallel(optional): The number of parallel workers. Defaults to 1.browsers(optional): The browsers to run the tests in. Defaults tochrome. Possible values arechrome,firefox,edge.additional-dependencies(optional): An array of additional dependencies to install. These are usually dependencies you are using inside the cypress folder (e.g. plugins). You can specify the version with @1.0.0. (e.g."@cypress/foo@^1.1.0")cypressFolder(optional): The name of the folder containing your cypress tests. Defaults tocypress.cypressConfig(optional): The name of the cypress config file, can be a glob. Defaults tocypress.{config.{js,ts},json}.specFiles(optional): The glob pattern to match the spec files. Defaults tocypress/integrations/**/*.{spec|test|e2e|integration}.{js,ts}.
Running tests
In the same directory as your testkit.json file, run the following command:
testkit cypress run
This will launch remote browsers and run your tests. You can fine-tune the configuration for each test run by adding flags.
For example:
testkit cypress run --parallel 2 --browsers firefox
Flags
Flags can overwrite options from your testkit.json or defaults.
-o, --org=<value>- (required) The organization id (find this in the menu on the left in the Testkit app)-c, --config=<value>- (required) Path to the testkit config file, defaults totestkit.json-C, --cypressConfig=<value>- (optional) The path to the cypress config file, defaults tocypress.{config.{js,ts},json}-b, --browsers=<value>- (optional) Browsers to run the tests in, comma separated. Available: chrome,firefox,edge-d, --additionalDependencies=<value>- (optional) Additional npm dependencies to install before running tests (comma seperated). This is usually every package you use in your tests.-f, --cypressFolder=<value>- (optional) The path to the cypress directory, defaults to the cypress directory where the testkit config file is located-p, --parallel=<value>- (optional) The number of parallel runners, defaults to 1-s, --specFiles=<value>- (optional) The path to the spec files, defaults to cypress/integrations/**/*.{spec|test|e2e|integration}.{js,ts}
Troubleshooting
If you have any unexpected errors or problems, feel free to contact us at support@testkit.app, and we'll help you.