This script illustrates the basic set up of a test that runs in the Sauce Labs virtual browser cloud. It includes using environment variables for authentication credentials, using tags and build numbers for test result management, and reporting the Pass/Fail status of the test to the Sauce Labs dashboard.
The code in this topic is presented as an example only, since your tests and testing environments may require specialized scripting. This information should be taken only as an illustration of how you could set up your tests with Sauce Labs, and is not directly supported by Sauce.
What You'll Need
- You should have a Sauce Labs account
- You should review the Best Practices for Running Tests
Setup Example Script
When this script runs, it opens the browser specified in the script, navigates to the saucelabs.demo web app, and then closes the browser. If you want to run this script using your Sauce Labs credentials and have it navigate to your own web app:
- Follow the instructions in Best Practice: Use Environment Variables for Authentication Credentials to set up your Sauce Labs account access.
- Enter the URL for the web app you want to test in the place of
- Once you've been able to run the test against your web app, you can use the Platform Configurator to experiment with changing the desired capabilities of the test.
Download this script from saucelabs-training on GitHub: https://github.com/saucelabs-training/demo-js/blob/master/on-boarding-modules/mocha-examples/test/module4-mocha-test.js