Skip to main content
No Result Found

Test Observability on Cypress

Quick start guide to integrate BrowserStack Test Observability with Cypress

Prerequisites

  • You have an account with BrowserStack (even a free trial works) and can get your Username and Access Key from your account profile.
  • You have a Cypress v10 or above test suite (it is okay even if you do not run your tests on BrowserStack infrastructure).

Integrate with Test Observability

BrowserStack Test Observability can be used regardless of where your tests run - whether on BrowserStack’s devices and browsers, locally on your laptop, CI machines, or using another cloud provider.

Please note that Test Observability currently cannot be used alongside existing test reporters like mochawesome, and will automatically disable any other reporters you have set up.

Please select your setup below to get started with an awesome debugging experience with Test Observability:

Follow these steps to start using BrowserStack Test Observability with your existing setup of Cypress tests running on BrowserStack Automate.

Install the latest version of the browserstack-cypress-cli npm package

Update the browserstack-cypress-cli using the following commands.

Terminal
Copy icon Copy

Make changes to the browserstack.json file

If you’ve installed the browserstack-cypress-cli for the first time, you’d have to create the browserstack.json file in the root of your directory. Else, just verify that your config file has all the required key-value pairs as in the following snippet:

The projectName and buildName config must be static and not change across different runs of the same build. This is a deviation in approach as specified by BrowserStack Automate or App Automate as Test Observability will automatically identify different build runs.

Restrict the characters in your projectName and buildName to alphanumeric characters (A-Z, a-z, 0-9), underscores (_), colons (:), and hyphens (-). Any other character will be replaced with a space.

browserstack.json
Copy icon Copy

Make changes to the cypress.config.js file

You’ll need to make a minor modification to the cypress.config.js file to import and use the Test Observability plugin while your tests run. Ensure the lines mentioned in the sample file below are present in your config file.

cypress.config.js
Copy icon Copy

Run your suite with BrowserStack Test Observability

Use the existing command that you use to trigger a run as shown below and data will automatically start getting sent to BrowserStack Test Observability.

Terminal
Copy icon Copy


Post build run completion, you will see the build URL of Test Observability in your console. Alternatively, you can also navigate to your build using Build Runs.


Visit Test Observability

Follow these steps to start using BrowserStack Test Observability with your existing setup of Cypress tests running locally or on another cloud.

Install the latest version of the browserstack-cypress-cli npm package

Install the browserstack-cypress-cli using the following commands.

Terminal
Copy icon Copy

Create the browserstack.json file

Create the browserstack.json file in the root of your directory with the following key-value pairs.

browserstack.json
Copy icon Copy

Modify the cypress.config.js file

You’ll need to make a minor modification to the cypress.config.js file to import and use the Test Observability plugin while your tests run. Ensure the lines mentioned in the sample file below are present in your config file.

cypress.config.js
Copy icon Copy

Run your suite with BrowserStack Test Observability

Use the existing command that you use to trigger a run and data will automatically start getting sent to BrowserStack Test Observability.

Terminal
Copy icon Copy


Post build run completion, you will see the build URL of Test Observability in your console. Alternatively, you can also navigate to your build run using Build Runs.


Visit Test Observability

Troubleshooting & FAQs

Why am I getting `Error loading the reporter` in my terminal?

You might get the following error in your Terminal when you try running tests:

Error loading the reporter: browserstack-cypress-cli/bin/testObservability/reporter

We searched for the reporter in these paths:

 - ./browserstack-cypress-cli/bin/testObservability/reporter
 - ./node_modules/browserstack-cypress-cli/bin/testObservability/reporter


If you get this error, try running the prescribed test command with --force-upload appended.

For example:

npx browserstack-cypress run <any other flags like --spec, --sync etc.> --force-upload

Why am I getting `Error: Cannot not find module` in my terminal?

You might get the following error in your Terminal when you try running tests:

Error: Cannot find module './node_modules/browserstack-cypress-cli/bin/testObservability/reporter'


If you get this error, try running the prescribed test command with --force-upload appended.

For example:

npx browserstack-cypress run <any other flags like --spec, --sync etc.> --force-upload

Why is my existing test reporter not working when I run tests using Test Observability?

When you use Test Observability, your existing reporters (like mochawesome) are automatically disabled. In order to use your existing reporter again, please disable Test Observability by setting "testObservability": false in your browserstack.json file.

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