Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Provide access to the processed configuration block #1724

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/referenceConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ exports.config = {
// are using Jasmine, you can add a reporter with:
// jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter(
// 'outputdir/', true, true));
//
// As a convenience, if you need access back to the current configuration
// object, you may use a pattern like the following:
// browser.getProcessedConfig().then(function(config) {
// // config.capabilities is the CURRENT capability being run, if
// // you are using multiCapabilities.
// console.log('Executing capability', config.capabilities);
// });
},

// A callback function called once tests are finished.
Expand Down
11 changes: 11 additions & 0 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ Runner.prototype.createBrowser = function() {
}
var self = this;

/**
* Get the processed configuration object that is currently being run.
*
* @return {q.Promise} A promise which resolves on finish.
*/
browser_.getProcessedConfig = function() {
var deferred = q.defer();
deferred.resolve(config);
return deferred.promise;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just do

return q(config);

I'll switch it.

};

/**
* Fork another instance of protractor for use in interactive tests.
*
Expand Down
11 changes: 11 additions & 0 deletions spec/basic/processedconfig_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var util = require('util');

describe('configuration elements', function() {
it('should have access to the processed config block', function() {
browser.getProcessedConfig().then(function(config) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will actually fail in our CI where the browser is not always Chrome - I'll modify slightly.

expect(config.capabilities.browserName).toEqual('chrome');
expect(config.capabilities.version).toEqual('ANY');
expect(config.params.login.name).toEqual('Jane');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a quick note - the test will not wait for this 'then' block (and so not execute these tests) since it's a q promise and not a webdriver promise. I'm resolving this by making getProcessedConfig return a webdriver promise, so that it will automatically be waited for.

});
});
});