From c30afddb80b6138fc5f648f70f2891067d8eeef4 Mon Sep 17 00:00:00 2001 From: Sammy Jelin Date: Tue, 25 Aug 2015 15:58:13 -0700 Subject: [PATCH] fix(test): fixed tests under npm test --- lib/runner.js | 12 +++++------- plugins/console/spec/fail_error_spec.js | 8 ++++---- plugins/console/spec/fail_spec.js | 10 +++++----- plugins/console/spec/fail_warning_spec.js | 8 ++++---- spec/basic/expected_conditions_spec.js | 4 ++-- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/lib/runner.js b/lib/runner.js index dec5e7eb3..96aed4e74 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -175,7 +175,7 @@ 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(); @@ -183,6 +183,7 @@ Runner.prototype.createBrowser = function() { config.baseUrl, config.rootElement); browser_.params = config.params; + browser_.plugins_ = plugins; if (config.getPageTimeout) { browser_.getPageTimeout = config.getPageTimeout; } @@ -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_; } @@ -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; @@ -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 ' + @@ -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() { diff --git a/plugins/console/spec/fail_error_spec.js b/plugins/console/spec/fail_error_spec.js index c0658b0ee..bb2099b69 100644 --- a/plugins/console/spec/fail_error_spec.js +++ b/plugins/console/spec/fail_error_spec.js @@ -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(); }); }); diff --git a/plugins/console/spec/fail_spec.js b/plugins/console/spec/fail_spec.js index 95a11f8a5..d9b993bc2 100644 --- a/plugins/console/spec/fail_spec.js +++ b/plugins/console/spec/fail_spec.js @@ -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(); @@ -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(); + }); }); diff --git a/plugins/console/spec/fail_warning_spec.js b/plugins/console/spec/fail_warning_spec.js index 58af6b6c4..11e2c3dce 100644 --- a/plugins/console/spec/fail_warning_spec.js +++ b/plugins/console/spec/fail_warning_spec.js @@ -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(); }); }); diff --git a/spec/basic/expected_conditions_spec.js b/spec/basic/expected_conditions_spec.js index 9ccf3e4b7..854bdc8fa 100644 --- a/spec/basic/expected_conditions_spec.js +++ b/spec/basic/expected_conditions_spec.js @@ -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(); });