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

Commit

Permalink
fix(test): fixed tests under npm test
Browse files Browse the repository at this point in the history
  • Loading branch information
sjelin committed Aug 25, 2015
1 parent 8f93938 commit c30afdd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
12 changes: 5 additions & 7 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,15 @@ Runner.prototype.setupGlobals_ = function(browser_) {
* @return {Protractor} a protractor instance.
* @public
*/
Runner.prototype.createBrowser = function() {
Runner.prototype.createBrowser = function(plugins) {
var config = this.config_;
var driver = this.driverprovider_.getNewDriver();

var browser_ = protractor.wrapDriver(driver,
config.baseUrl, config.rootElement);

browser_.params = config.params;
browser_.plugins_ = plugins;
if (config.getPageTimeout) {
browser_.getPageTimeout = config.getPageTimeout;
}
Expand All @@ -203,7 +204,7 @@ Runner.prototype.createBrowser = function() {
};

browser_.forkNewDriverInstance = function(opt_useSameUrl, opt_copyMockModules) {
var newBrowser = self.createBrowser();
var newBrowser = self.createBrowser(plugins);
if (opt_copyMockModules) {
newBrowser.mockModules_ = browser_.mockModules_;
}
Expand Down Expand Up @@ -239,7 +240,7 @@ Runner.prototype.shutdown_ = function() {
Runner.prototype.run = function() {
var self = this,
testPassed,
plugins,
plugins = new Plugins(self.config_),
pluginPostTestPromises,
browser_,
results;
Expand All @@ -252,8 +253,7 @@ Runner.prototype.run = function() {
//noinspection JSValidateTypes
return this.driverprovider_.setupEnv().then(function() {
// 2) Create a browser and setup globals
}).then(function() {
browser_ = self.createBrowser();
browser_ = self.createBrowser(plugins);
self.setupGlobals_(browser_);
return browser_.ready.then(browser_.getSession).then(function(session) {
log.debug('WebDriver session successfully started with capabilities ' +
Expand All @@ -264,8 +264,6 @@ Runner.prototype.run = function() {
});
// 3) Setup plugins
}).then(function() {
plugins = new Plugins(self.config_);
browser_.plugins_ = plugins;
return plugins.setup();
// 4) Execute test cases
}).then(function() {
Expand Down
8 changes: 4 additions & 4 deletions plugins/console/spec/fail_error_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ describe('console plugin', function() {
var logMessageButton = element(by.id('log-message'));
var deleteMessageButton = element(by.id('simulate-error'));

it('should not fail on log and debug messages', function() {
it('should fail on error message', function() {
browser.get('console/index.html');
logMessageButton.click();
deleteMessageButton.click();
});

it('should fail on error message', function() {
it('should not fail on log and debug messages', function() {
browser.get('console/index.html');
deleteMessageButton.click();
logMessageButton.click();
});
});
10 changes: 5 additions & 5 deletions plugins/console/spec/fail_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ describe('console plugin', function() {
var warningMessageButton = element(by.id('simulate-warning'));
var deleteMessageButton = element(by.id('simulate-error'));

it('should not fail on log and debug messages', function() {
browser.get('console/index.html');
logMessageButton.click();
});

it('should fail on warning message', function() {
browser.get('console/index.html');
warningMessageButton.click();
Expand All @@ -18,4 +13,9 @@ describe('console plugin', function() {
browser.get('console/index.html');
deleteMessageButton.click();
});

it('should not fail on log and debug messages', function() {
browser.get('console/index.html');
logMessageButton.click();
});
});
8 changes: 4 additions & 4 deletions plugins/console/spec/fail_warning_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ describe('console plugin', function() {
var logMessageButton = element(by.id('log-message'));
var warningMessageButton = element(by.id('simulate-warning'));

it('should not fail on log and debug messages', function() {
it('should fail on warning message', function() {
browser.get('console/index.html');
logMessageButton.click();
warningMessageButton.click();
});

it('should fail on warning message', function() {
it('should not fail on log and debug messages', function() {
browser.get('console/index.html');
warningMessageButton.click();
logMessageButton.click();
});
});
4 changes: 2 additions & 2 deletions spec/basic/expected_conditions_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ describe('expected conditions', function() {
browser.get('index.html#/form');
});

it('should have alertIsPresent', function() {
fit('should have alertIsPresent', function() {
var alertIsPresent = EC.alertIsPresent();
expect(alertIsPresent.call()).toBe(false);

var alertButton = $('#alertbutton');
alertButton.click();
expect(alertIsPresent.call()).toBe(true);
browser.wait(protractor.ExpectedConditions.alertIsPresent(), 1000);

browser.switchTo().alert().accept();
});
Expand Down

0 comments on commit c30afdd

Please sign in to comment.