Skip to main content

Test Observability on Jest.js

Quick start guide to integrate BrowserStack Test Observability with Jest.js

Prerequisites

  • You have an account with BrowserStack (even a free trial works) and can get your Username and Access Key from Settings.
  • You have a Jest.js v26.0 or higher test suite, (it is okay even if you do not run your tests on BrowserStack infrastructure).
  • You use Node version 14 or higher.

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.

Not only that, Test Observability is agnostic to the type of testing and hence you could also integrate it with your unit or integration test suite written using Jest.

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

Install or update to the latest version of BrowserStack Node SDK

Go to your Jest project’s root directory and run the following commands to update or install the BrowserStack Node SDK and verify the installed version:

Terminal
Copy icon Copy snippet


Please ensure that you have at least browserstack-node-sdk v1.30.0 before proceeding.

Create the browserstack.yml file

Run the following command to create a browserstack.yml file:

Terminal
Copy icon Copy snippet

Modify the browserstack.yml file

Update the following configurations in the browserstack.yml file:

browserstack.yml
Copy icon Copy snippet

The projectName and buildName config must be static and not change across different runs of the same build. 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.

Please note that if you are running tests on BrowserStack Automate already, this SDK is only for Test Observability and will not override the capabilities you have configured in browserstack.config.js. This means if you want to have the same build & project names across Test Observability & BrowserStack Automate, you need to maintain the same values across both browserstack.config.js and browserstack.yml.

Run your test suite with Test Observability

Prepend browserstack-node-sdk to 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 snippet


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


Visit Test Observability

Install or update to the latest version of BrowserStack Node SDK

Go to your Jest project’s root directory and run the following commands to update or install the BrowserStack Node SDK and ensure that you have the latest version:

Terminal
Copy icon Copy snippet


Ensure that you now have at least browserstack-node-sdk v1.21.1 before proceeding.

Set up the browserstack.yml file

Set up the browserstack.yml file as in the following code sample:

browserstack.yml
Copy icon Copy snippet

The projectName and buildName config must be static and not change across different runs of the same build. 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.

Run your test suite with Test Observability

Prepend browserstack-node-sdk to 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 snippet


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


Visit Test Observability

Install or update to the latest version of BrowserStack Node SDK

Go to your Jest project’s root directory and run the following commands to update or install the BrowserStack Node SDK and verify the installed version:


Please ensure that you now have at least browserstack-node-sdk v1.30.0 before proceeding.

Terminal
Copy icon Copy snippet

Create the browserstack.yml file

Run the following command to set your username and accesskey as environment variables:

Terminal
Copy icon Copy snippet

Modify the browserstack.yml file

Set up the browserstack.yml file as follows:

browserstack.yml
Copy icon Copy snippet

The projectName and buildName config must be static and not change across different runs of the same build. 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.

Run your test suite with Test Observability

Prepend browserstack-node-sdk to 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 snippet


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


Visit Test Observability

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