Skip to main content
Experience faster, smarter testing with BrowserStack AI Agents. See what your workflow’s been missing. Explore now!
No Result Found
Connect & Get help from fellow developers on our Discord community. Ask the CommunityAsk the Community

Run your first Cypress test

Learn how to use the Kitchen Sink example app to run your first test on BrowserStack.

If you are still using the older dashboard, see the documentation for the old dashboard.

In this tutorial, you use Cypress’ Kitchen Sink example app to run tests. This app helps demonstrate how Cypress works.

This guide covers:

Prerequisites

To run your Typescript test with Cypress, check out our Typescript repository.

Run your first test

To run your first Cypress test with BrowserStack, perform the following steps:

Step 1: Install the BrowserStack CLI. The BrowserStack - Cypress CLI is a command-line tool that is used to enable communication between Cypress and BrowserStack. Use the npm command to install the BrowserStack - Cypress CLI as follows:

Command Line
# Install the BrowserStack Cypress CLI
npm install -g browserstack-cypress-cli

Step 2: Clone the Kitchen Sink app using the following command:

# Clone the Kitchen Sink repo for Cypress v10 and higher
git clone https://github.com/cypress-io/cypress-example-kitchensink.git && cd cypress-example-kitchensink
# Clone the Kitchen Sink repo for Cypress v9 and lower
git clone https://github.com/cypress-io/cypress-example-kitchensink.git && cd cypress-example-kitchensink && git checkout ab10094ef7b199ae7febafec413a0626414bcd3c

After you clone the repository, the Cypress project will be in the following structure:

app
...
cypress
|-- fixtures
|-- e2e
|-- support
cypress.config.js
...
app
...
cypress
|-- fixtures
|-- integration
|-- plugins
|-- support
cypress.json
...

Step 3: Use the npm command to install dependent node modules required to run the Kitchen Sink example app:

Command Line
npm install

Step 4: Create and configure the browserstack.json file which contains configurations, such as BrowserStack credentials, capabilities, etc., that are required for running the tests. Use the following init command to initialize the app project folder and create a boilerplate browserstack.json file:

Command Line
browserstack-cypress init

After you create the browserstack.json file, add or modify the mandatory configurations required to run the Cypress tests, as shown in the following sample. These configurations include your BrowserStack credentials, the Cypress configuration file, browser-device combinations, and the number of parallels.

Check out the supported devices and browsers to configure the testing combinations.

// browserstack.json

{
  "auth": {
    "username": "YOUR_USERNAME",
    "access_key": "YOUR_ACCESS_KEY"
  },
  "browsers": [{
      "browser": "chrome",
      "os": "Windows 10",
      "versions": ["latest", "latest - 1"]
    },
    {
      "browser": "firefox",
      "os": "OS X Mojave",
      "versions": ["latest", "latest - 1"]
    },
    {
      "browser": "edge",
      "os": "OS X Catalina",
      "versions": ["latest"]
    }
  ],
  "run_settings": {
    "cypress_config_file": "./cypress.config.js",
    // For Cypress v9 or lower using the following configuration
    // "cypress_config_file": "./cypress.json",
    "cypress_version": "13.latest",
    "npm_dependencies": {
      "add-your-npm-package-1-for-test-run-here": "npm-package-version",
      "add-your-npm-package-2-for-test-run-here": "npm-package-version"
    },
    "project_name": "Cypress Kitchen Sink Example",
    "build_name": "Build no: 1",
    "parallels": 5,
    "exclude": ["some-folder/test.js", "static/*.pdf"]
  }
}

If you are using any external npm packages in your Cypress tests, add those under npm_dependencies in the browserstack.json file.

Step 5: Set up the application server. The Kitchen sink sample app can be tested on BrowserStack using either the localhost website or using Cypress Kitchen Sink sample app public URL.

If you want to run the Cypress test using the Kitchen Sink web app hosted publicly at https://example.cypress.io/, you must replace all localhost URL instances with the public URL in the project folder.

Step 6: In your IDE, open the Kitchen Sink App project.

Step 7: Search the project for http://localhost:8080, and then replace all instances with https://example.cypress.io as shown in the following IDE sample:Cypress kitchen sink replace localhost

Ensure that you replace the instances in all *.spec.js files.

Step 8: Set the following Local configurations to the connection_settings object in your browserstack.json file:

  //browserstack.json
  ...
  "connection_settings": {
          "local": false,
      }
  ...

The tests in Kitchen Sink example use the http:\\localhost:8080 URL to access the application server. Use the following steps to start the application server.

Check out the Cypress Kitchen Sink’s README for more information.

Step 6: Set up Local testing. Set the following Local configurations to the connection_settings object in your browserstack.json file:

//browserstack.json
...
"connection_settings": {
        "local": true,
        "local_identifier": "My_Sample_Tutorial"
    }
...

Step 7: Start the webserver using the following command:

npm start

Step 8: Verify the app is hosted.

Verify that the Kitchen Sink web app is hosted at http://localhost:8080.

Step 9: Run the test using the following command:

Command Line
browserstack-cypress run

View your test results

After you run your test, visit the Automate dashboard to view your test results as follows:

BrowserStack Automate Dashboard showing Cypress tests

All tests in each spec file are grouped by browser combination. When you click a browser combination, you see a detailed view with video logs, text logs, and more. If any test fails, relevant screenshots appear in the Screenshots tab.

On your command-line tool, you see completed tests and their current status as the build runs. After execution, test results are saved in the results folder, which contains HTML and JSON files with the build summary.

Level up your Cypress testing on BrowserStack with Test Reporting & Analytics - with advanced test reporting, debugging, smart failure analysis, and rich insights for your test suites.

works automatically for all users running Cypress v10 and above. You can explicitly turn off Test Reporting & Analytics by turning the testObservability flag to false. You can explore additional configurations and learn how to use Test Reporting & Analytics for Cypress here.

Test Reporting & Analytics currently doesn’t support other test reporters like Mochawesome. If any are set up, they are automatically disabled.

Test Reporting & Analytics Dashboard

Next Steps

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle