forked from nightwatchjs/nightwatch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into features/parallel-execution
* master: fixed a problem with showing redundant output summary fixed a problem with the logger updated sample nightwatch.json small refactoring to make it more consistent with the rest of assertions Corrected errors in the tests for urlContains and urlEquals Update testUrlEquals.js Create testUrlContains.js Create testUrlEquals.js Create urlContains.js Add urlEquals assertion refactor: reduce function calls for logTimestamp chore: rename logTimestap to logTimestamp style: break some overlong lines style: satisfy jshint indention warnings
- Loading branch information
Showing
7 changed files
with
234 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Checks if the current URL contains the given value. | ||
* | ||
* ``` | ||
* this.demoTest = function (client) { | ||
* browser.assert.urlContains('google'); | ||
* }; | ||
* ``` | ||
* | ||
* @method urlContains | ||
* @param {string} expected The value expected to exist within the current URL. | ||
* @param {string} [message] Optional log message to display in the output. If missing, one is displayed by default. | ||
* @api assertions | ||
*/ | ||
|
||
var util = require('util'); | ||
exports.assertion = function(expected, msg) { | ||
|
||
this.message = msg || util.format('Testing if the URL contains "%s".', expected); | ||
this.expected = expected; | ||
|
||
this.pass = function(value) { | ||
return value.indexOf(this.expected) > -1; | ||
}; | ||
|
||
this.value = function(result) { | ||
return result.value; | ||
}; | ||
|
||
this.command = function(callback) { | ||
this.api.url(callback); | ||
return this; | ||
}; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Checks if the current url equals the given value. | ||
* | ||
* ``` | ||
* this.demoTest = function (client) { | ||
* browser.assert.urlEquals('http://www.google.com'); | ||
* }; | ||
* ``` | ||
* | ||
* @method urlEquals | ||
* @param {string} expected The expected url. | ||
* @param {string} [message] Optional log message to display in the output. If missing, one is displayed by default. | ||
* @api assertions | ||
*/ | ||
|
||
var util = require('util'); | ||
exports.assertion = function(expected, msg) { | ||
|
||
this.message = msg || util.format('Testing if the URL equals "%s".', expected); | ||
this.expected = expected; | ||
|
||
this.pass = function(value) { | ||
return value === this.expected; | ||
}; | ||
|
||
this.value = function(result) { | ||
return result.value; | ||
}; | ||
|
||
this.command = function(callback) { | ||
this.api.url(callback); | ||
return this; | ||
}; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
var BASE_PATH = process.env.NIGHTWATCH_COV | ||
? 'lib-cov' | ||
: 'lib'; | ||
var Api = require('../../../'+BASE_PATH+'/core/api.js'); | ||
module.exports = { | ||
setUp: function (callback) { | ||
callback(); | ||
}, | ||
|
||
'urlContains assertion passed' : function(test) { | ||
var assertionFn = require('../../../'+BASE_PATH+'/selenium/assertions/urlContains.js'); | ||
var client = { | ||
options : {}, | ||
api : { | ||
url : function(callback) { | ||
callback({ | ||
value : 'http://www.nightwatchjs.org' | ||
}); | ||
} | ||
}, | ||
assertion : function(passed, result, expected, msg, abortOnFailure) { | ||
test.equals(passed, true); | ||
test.equals(result, 'http://www.nightwatchjs.org'); | ||
test.equals(expected, 'nightwatchjs'); | ||
test.equals(msg, 'Testing if the URL contains "nightwatchjs".'); | ||
test.equals(abortOnFailure, true); | ||
delete assertionFn; | ||
test.done(); | ||
} | ||
}; | ||
Api.init(client); | ||
var m = Api.createAssertion('urlContains', assertionFn, true, client); | ||
m._commandFn('nightwatchjs'); | ||
}, | ||
|
||
'urlContains assertion failed' : function(test) { | ||
var assertionFn = require('../../../'+BASE_PATH+'/selenium/assertions/urlContains.js'); | ||
var client = { | ||
options : {}, | ||
api : { | ||
url : function(callback) { | ||
callback({ | ||
value : 'http://www.nightwatchjs.org' | ||
}); | ||
} | ||
}, | ||
assertion : function(passed, result, expected, msg, abortOnFailure) { | ||
test.equals(passed, false); | ||
test.equals(result, 'http://www.nightwatchjs.org'); | ||
test.equals(expected, 'google'); | ||
test.equals(abortOnFailure, true); | ||
delete assertionFn; | ||
test.done(); | ||
} | ||
}; | ||
Api.init(client); | ||
var m = Api.createAssertion('urlContains', assertionFn, true, client); | ||
m._commandFn('google'); | ||
}, | ||
|
||
tearDown : function(callback) { | ||
callback(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
var BASE_PATH = process.env.NIGHTWATCH_COV | ||
? 'lib-cov' | ||
: 'lib'; | ||
var Api = require('../../../'+BASE_PATH+'/core/api.js'); | ||
module.exports = { | ||
setUp: function (callback) { | ||
callback(); | ||
}, | ||
|
||
'urlEquals assertion passed' : function(test) { | ||
var assertionFn = require('../../../'+BASE_PATH+'/selenium/assertions/urlEquals.js'); | ||
var client = { | ||
options : {}, | ||
api : { | ||
url : function(callback) { | ||
callback({ | ||
value : 'http://www.nightwatchjs.org' | ||
}); | ||
} | ||
}, | ||
assertion : function(passed, result, expected, msg, abortOnFailure) { | ||
test.equals(passed, true); | ||
test.equals(result, 'http://www.nightwatchjs.org'); | ||
test.equals(expected, 'http://www.nightwatchjs.org'); | ||
test.equals(msg, 'Testing if the URL equals "http://www.nightwatchjs.org".'); | ||
test.equals(abortOnFailure, true); | ||
delete assertionFn; | ||
test.done(); | ||
} | ||
}; | ||
Api.init(client); | ||
var m = Api.createAssertion('urlEquals', assertionFn, true, client); | ||
m._commandFn('http://www.nightwatchjs.org'); | ||
}, | ||
|
||
'urlEquals assertion failed' : function(test) { | ||
var assertionFn = require('../../../'+BASE_PATH+'/selenium/assertions/title.js'); | ||
var client = { | ||
options : {}, | ||
api : { | ||
title : function(callback) { | ||
callback({ | ||
value : 'http://www.nightwatchjs.org' | ||
}); | ||
} | ||
}, | ||
assertion : function(passed, result, expected, msg, abortOnFailure) { | ||
test.equals(passed, false); | ||
test.equals(result, 'http://www.nightwatchjs.org'); | ||
test.equals(expected, 'http://www.google.com'); | ||
test.equals(abortOnFailure, true); | ||
delete assertionFn; | ||
test.done(); | ||
} | ||
}; | ||
Api.init(client); | ||
var m = Api.createAssertion('urlEquals', assertionFn, true, client); | ||
m._commandFn('http://www.google.com'); | ||
}, | ||
|
||
tearDown : function(callback) { | ||
callback(); | ||
} | ||
} |