3. How To Test¶
3.1. Initial Common Steps¶
3.1.1. Environment Settings¶
3.1.1.1. BrowserStack¶
$ export BROWSERSTACK_USERNAME=<your-browserstack-username>
$ export BROWSERSTACK_ACCESS_KEY=<your-browserstack-access-key>
3.1.1.2. SauceLabs¶
$ export SAUCE_USERNAME=<your-saucelabs-username>
$ export SAUCE_ACCESS_KEY=<your-saucelabs-access-key>
3.1.1.3. CrossBrowserTesting¶
$ export CROSSBROWSERTESTING_USERNAME=<your-crossbrowsertesting-username>
$ export BROWSECROSSBROWSERTESTINGRSTACK_ACCESS_KEY=<your-crossbrowsertesting-access-key>
3.1.2. Update Supported Browsers (Optional)¶
See Platform Configuration for the significance and details of this step.
Replace {platform}
in the command below with any of: browserstack
, saucelabs
, crossbrowsertesting
.
$ ./node_modules/.bin/cbtr-{platform}-update
3.1.3. Specify Your Browsers¶
See Browsers YAML for details on how to specify browsers for your tests.
Here is a list of few sample files you can use, if you want to understand the format later:
- BrowserStack sample:
./node_modules/cross-browser-tests-runner/samples/yml/browserstack.yml
- SauceLabs sample:
./node_modules/cross-browser-tests-runner/samples/yml/saucelabs.yml
- CrossBrowserTesting sample:
./node_modules/cross-browser-tests-runner/samples/yml/crossbrowsertesting.yml
3.1.4. Generate Test Settings¶
See Settings for details on the JSON format test settings cross-browser-tests-runner
uses.
Generate it using the following command that uses the browsers YAML file as input:
$ ./node_modules/.bin/cbtr-init --input <path-to-browsers-yml-file> --output <path-to-settings-file>
See cbtr-init for usage and how to use defaults for the command line input options.
3.2. JavaScript Unit Testing¶
First complete the Initial Common Steps, as applicable.
3.2.1. Using Native Runner¶
To run your tests using Native Runner, add the following parameters in your test settings file:
framework
(See Parameters) - the JavaScript unit test framework used in your teststest_file
(See Parameters) - the local HTML file that your test would open (See Test HTML)
Run the following:
$ ./node_modules/.bin/cbtr-server --native-runner --config <path-to-settings-file>
This would run all your tests and exit once completed.
See Server for details on cbtr-server
command.
3.2.2. Using Testem¶
Generate the Testem configuration file testem.json
for your platform.
Replace {platform} in the command below with one of: browserstack
, saucelabs
, crossbrowsertesting
.
$ ./node_modules/.bin/cbtr-testem-{platform}-init --input <path-to-settings-file> --output <path-to-testem-json>
It would overwritelaunchers
andlaunch_in_ci
settings in an existing testem settings file
See the following for details on platform-specific executable binaries for generating testem settings:
Run the cross-browser-tests-runner server using the following command:
$ ./node_modules/.bin/cbtr-server &
Now run testem in CI mode as follows:
$ testem ci
3.3. Selenium Testing¶
First complete the Initial Common Steps, as applicable.
Add the following parameters in the test settings file:
test_file
(See Parameters) - the local HTML file that your test would opentest_script
(See Parameters) - a file that contains your Selenium test script (See Test Script)
Run the cross-browser-tests-runner server using the following command:
$ ./node_modules/.bin/cbtr-server --native-runner --config <path-to-settings-file>
This would run all your tests and exit once completed.