Test Observability on MochaJS
Quick start guide to integrate BrowserStack Test Observability with MochaJS
Prerequisites
- You have an account with BrowserStack (even a free trial works) and can get the Username and Access Key from your account profile.
- You have a Mocha test suite (it is okay even if you do not run your tests on BrowserStack infrastructure).
Integrate with Test Observability
You can use BrowserStack Test Observability both when you’re using BrowserStack’s devices and browsers to run your tests and also if you’re running tests locally on your laptop/CI system or even when you’re using some other cloud provider.
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 mochaJS tests running on BrowserStack Automate or App Automate:
Install the latest version of the browserstack-node-sdk npm package
You’d need to install/update the browserstack-node-sdk
as shown below:
Please ensure that you have at least browserstack-node-sdk v1.32.2
before proceeding.
Make changes to the SDK config file
If you’ve installed the browserstack-node-sdk
for the first time, you’d have to create the browserstack.yml
file shown below. Else, just verify that your config file has all the required key-value pairs.
Create a browserstack.yml
file in the root folder of your test suite if it doesn’t exist.
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 SDK is a very powerful tool that you can use to set the different browser/device combinations and parallelization. For more details, check out the Automate Integration guide
Run your suite with BrowserStack 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.
Note: In case you’ve used double quotes in the command (" ")
after browserstack-node-sdk
, ensure you remove them. Otherwise, you might get the following error: Not a valid command. Check help and provide a valid command.
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.
Follow these steps to start using BrowserStack Test Observability with your mochaJS tests running locally/CI or even on any other cloud platform:
Install the latest version of the browserstack-node-sdk npm package
You’d need to install the browserstack-node-sdk
using the following command:
Please ensure that you have at least browserstack-node-sdk v1.32.2
before proceeding.
Create the SDK config file
Create browserstack.yml
file in the root folder of your test suite and copy the below code into it.
Run your suite with BrowserStack Test Observability
Prepend BROWSERSTACK_AUTOMATION=false browserstack-node-sdk
to the existing command that you use to trigger a run as shown below and data will automatically start getting sent to BrowserStack Test Observability.
Note: In case you’ve used double quotes in the command (" ")
after browserstack-node-sdk
, ensure you remove them. Otherwise, you might get the following error: Not a valid command. Check help and provide a valid command.
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.
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
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!