Our friend Lubos Krnac describes how to integrate Sauce with Protractor in a quest to implement continuous integration in his JavaScript multi module project with Grunt. Below is a quote from his most recent blog post along side some code.
Read the rest of his post to get the full how-to here.
An important part of this setup is Protractor integration with Sauce Labs. Sauce Labs provides a Selenium server with WebDiver API for testing. Protractor uses Sauce Labs by default when you specify their credentials. Credentials are the only special configuration in test/protractor/protractorConf.js (bottom of the snippet). The other configuration was taken from the grunt-protractor-coverage example. I am using this Grunt plug-in for running Protractor tests and measuring code coverage.
1234567891011121314151617181920212223242526272829303132333435363738394041// A reference configuration file.
exports.config = {
// ----- What tests to run -----
//
// Spec patterns are relative to the location of this config.
specs: [
'test/protractor/*Spec.js'
],
// ----- Capabilities to be passed to the webdriver instance ----
//
// For a full list of available capabilities, see
// and
capabilities: {
'browserName'
:
'chrome'
// 'browserName': 'firefox'
// 'browserName': 'phantomjs'
},
params: {
},
// ----- More information for your tests ----
//
// A base URL for your application under test. Calls to protractor.get()
// with relative paths will be prepended with this.
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors:
true
,
// Use colors in the command line report.
isVerbose:
true
,
// List all tests in the console
includeStackTrace:
true
,
defaultTimeoutInterval: 90000
},
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY
};
You may ask "how can I use localhost in the configuration, when a remote selenium server is used for testing?" Good question. Sauce Labs provides a very useful feature called Sauce Connect. It is a tunnel that emulates access to your machine from a Selenium server. This is super useful when you need to bypass company firewall. It will be used later in main project CI configuration.