Mocha Integration with BrowserStack for E2E functional testing of UI using Selenium and browserstack-node-sdk.
- Clone the repo
- Install dependencies
npm install - Set your BrowserStack Username and Access Key in browserstack.yml
npx setup --username userName --key accessKey - To run sample test, run
npm run sample-testoryarn run sample-test - To run tests on private websites,
- set browserstackLocal: true at browserstack.yml
- run
npm run sample-local-testoryarn run sample-local-test
Integrate BrowserStack into your existing Mocha test suite using BrowserStack Node SDK — a plug-and-play solution that takes care of all the integration steps for you!
- Install browserstack-node-sdk as a dev-dependency in your mocha project
npm i -D browserstack-node-sdk
or
yarn add --dev browserstack-node-sdk
- Setup
npx setup --username userName --key accessKey
- Adds a browserstack.yml file at root of your mocha project with your BrowserStack Username and Access Key. Adding
userNameandaccessKeyin the config is not required if you have setenvvariables. - Adds a new command for running tests on browserstack in scripts property of package.json,
"scripts": {
"test": "mocha ...args",
"browserstack-test": "browserstack-node-sdk mocha ...args"
},
- You can view your test results on the BrowserStack automate dashboard
- To test on a different set of browsers, check out our capabilities generator
