Quick start guide to integrate BrowserStack Test Observability with CodeceptJS
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 CodeceptJS 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 CodeceptJS.
Install or update to the latest version of BrowserStack Node SDK
Go to your CodeceptJS project’s root directory and run the following commands to update or install the BrowserStack Node SDK and verify the installed version:
```bash
npm i -D browserstack-node-sdk@latest
npm list browserstack-node-sdk
```
Update the following configurations in the browserstack.yml file:
```yml
userName: YOUR_USERNAME
accessKey: YOUR_ACCESS_KEY
buildName: "Your static build/job name goes here"
projectName: "Your static project name goes here"
CUSTOM_TAG_1: "You can set a custom Build Tag here"
# Use CUSTOM_TAG_<N> and set more build tags as you need.
testObservability: true
browserstackAutomation: false # Set to true for tests on BrowserStack products.
...
```
userName: YOUR_USERNAME
accessKey: YOUR_ACCESS_KEY
buildName:"Your static build/job name goes here"projectName:"Your static project name goes here"CUSTOM_TAG_1:"You can set a custom Build Tag here"# Use CUSTOM_TAG_<N> and set more build tags as you need.testObservability:truebrowserstackAutomation:false# Set to true for tests on BrowserStack products....
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.
```bash
npx browserstack-node-sdk <Your existing command for running test suite>
```
Install or update to the latest version of BrowserStack Node SDK
Go to your CodeceptJS 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:
```bash
npm i -D browserstack-node-sdk@latest
npm list browserstack-node-sdk
```
npm i -D browserstack-node-sdk@latest
npm list browserstack-node-sdk
Ensure that you now have at least browserstack-node-sdk v1.32.6 before proceeding.
Set up the browserstack.yml file
Set up the browserstack.yml file as in the following code sample:
```yml
userName: "YOUR_USERNAME"
accessKey: "YOUR_ACCESS_KEY"
buildName: "Your static build/job name goes here"
projectName: "Your static project name goes here"
CUSTOM_TAG_1: "You can set a custom Build Tag here"
# Use CUSTOM_TAG_<N> and set more build tags as you need.
testObservability: true
browserstackAutomation: true
...
```
userName: "YOUR_USERNAME"
accessKey: "YOUR_ACCESS_KEY"
buildName: "Your static build/job name goes here"
projectName: "Your static project name goes here"
CUSTOM_TAG_1: "You can set a custom Build Tag here"# Use CUSTOM_TAG_<N> and set more build tags as you need.
testObservability: true
browserstackAutomation: true...
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.
```bash
npx browserstack-node-sdk <Your existing command for running test suite>
```
Install or update to the latest version of BrowserStack Node SDK
Go to your CodeceptJS 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.32.6 before proceeding.
```bash
npm i -D browserstack-node-sdk@latest
npm list browserstack-node-sdk
```
```yml
userName: YOUR_USERNAME
accessKey: YOUR_ACCESS_KEY
buildName: "Your static build/job name goes here"
projectName: "Your static project name goes here"
CUSTOM_TAG_1: "You can set a custom Build Tag here"
# Use CUSTOM_TAG_<N> and set more build tags as you need.
testObservability: true
browserstackAutomation: false # Set to true for tests on BrowserStack products.
...
```
userName: YOUR_USERNAME
accessKey: YOUR_ACCESS_KEY
buildName:"Your static build/job name goes here"projectName:"Your static project name goes here"CUSTOM_TAG_1:"You can set a custom Build Tag here"# Use CUSTOM_TAG_<N> and set more build tags as you need.testObservability:truebrowserstackAutomation:false# Set to true for tests on BrowserStack products....
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.
```bash
npx browserstack-node-sdk <Your existing command for running test suite>
```
To use CodeceptJS with Playwright or WebdriverIO, add the correct helper to the codecept.conf.js file.
The browserstack-node-sdk can be used with both the helpers to run tests on the BrowserStack infrastructure, or to run tests locally. You can set browserstackAutomation to true or false in the browserstack.yml file depending on where you want to execute your tests.
CodeceptJS with BDD
Test Observability supports BDD configuration in CodeceptJS. For this, ensure that your codecept.conf.js file is set up as described in the Codecept documentation.
CodeceptJS without Playwright or WebdriverIO
To use CodeceptJS with runners other than Playwright or WebdriverIO, add the correct helper to the codecept.conf.js file.
However, please ensure that browserstackAutomation is set to false in the browserstack.yml file. This is because BrowserStack Automate supports the direct execution of only Playwright and WebdriverIO test runners.
Did this page help you?
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
ON THIS PAGE
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