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

Commit c30afdd

Browse files
committed
fix(test): fixed tests under npm test
1 parent 8f93938 commit c30afdd

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

lib/runner.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,15 @@ Runner.prototype.setupGlobals_ = function(browser_) {
175175
* @return {Protractor} a protractor instance.
176176
* @public
177177
*/
178-
Runner.prototype.createBrowser = function() {
178+
Runner.prototype.createBrowser = function(plugins) {
179179
var config = this.config_;
180180
var driver = this.driverprovider_.getNewDriver();
181181

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

185185
browser_.params = config.params;
186+
browser_.plugins_ = plugins;
186187
if (config.getPageTimeout) {
187188
browser_.getPageTimeout = config.getPageTimeout;
188189
}
@@ -203,7 +204,7 @@ Runner.prototype.createBrowser = function() {
203204
};
204205

205206
browser_.forkNewDriverInstance = function(opt_useSameUrl, opt_copyMockModules) {
206-
var newBrowser = self.createBrowser();
207+
var newBrowser = self.createBrowser(plugins);
207208
if (opt_copyMockModules) {
208209
newBrowser.mockModules_ = browser_.mockModules_;
209210
}
@@ -239,7 +240,7 @@ Runner.prototype.shutdown_ = function() {
239240
Runner.prototype.run = function() {
240241
var self = this,
241242
testPassed,
242-
plugins,
243+
plugins = new Plugins(self.config_),
243244
pluginPostTestPromises,
244245
browser_,
245246
results;
@@ -252,8 +253,7 @@ Runner.prototype.run = function() {
252253
//noinspection JSValidateTypes
253254
return this.driverprovider_.setupEnv().then(function() {
254255
// 2) Create a browser and setup globals
255-
}).then(function() {
256-
browser_ = self.createBrowser();
256+
browser_ = self.createBrowser(plugins);
257257
self.setupGlobals_(browser_);
258258
return browser_.ready.then(browser_.getSession).then(function(session) {
259259
log.debug('WebDriver session successfully started with capabilities ' +
@@ -264,8 +264,6 @@ Runner.prototype.run = function() {
264264
});
265265
// 3) Setup plugins
266266
}).then(function() {
267-
plugins = new Plugins(self.config_);
268-
browser_.plugins_ = plugins;
269267
return plugins.setup();
270268
// 4) Execute test cases
271269
}).then(function() {

plugins/console/spec/fail_error_spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ describe('console plugin', function() {
33
var logMessageButton = element(by.id('log-message'));
44
var deleteMessageButton = element(by.id('simulate-error'));
55

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

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

plugins/console/spec/fail_spec.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ describe('console plugin', function() {
44
var warningMessageButton = element(by.id('simulate-warning'));
55
var deleteMessageButton = element(by.id('simulate-error'));
66

7-
it('should not fail on log and debug messages', function() {
8-
browser.get('console/index.html');
9-
logMessageButton.click();
10-
});
11-
127
it('should fail on warning message', function() {
138
browser.get('console/index.html');
149
warningMessageButton.click();
@@ -18,4 +13,9 @@ describe('console plugin', function() {
1813
browser.get('console/index.html');
1914
deleteMessageButton.click();
2015
});
16+
17+
it('should not fail on log and debug messages', function() {
18+
browser.get('console/index.html');
19+
logMessageButton.click();
20+
});
2121
});

plugins/console/spec/fail_warning_spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ describe('console plugin', function() {
33
var logMessageButton = element(by.id('log-message'));
44
var warningMessageButton = element(by.id('simulate-warning'));
55

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

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

spec/basic/expected_conditions_spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ describe('expected conditions', function() {
55
browser.get('index.html#/form');
66
});
77

8-
it('should have alertIsPresent', function() {
8+
fit('should have alertIsPresent', function() {
99
var alertIsPresent = EC.alertIsPresent();
1010
expect(alertIsPresent.call()).toBe(false);
1111

1212
var alertButton = $('#alertbutton');
1313
alertButton.click();
14-
expect(alertIsPresent.call()).toBe(true);
14+
browser.wait(protractor.ExpectedConditions.alertIsPresent(), 1000);
1515

1616
browser.switchTo().alert().accept();
1717
});

0 commit comments

Comments
 (0)