Skip to content

Commit 5cc2f3b

Browse files
robwierzbowskiyyx990803
authored andcommitted
Simplify elementCount custom assertions (vuejs-templates#898)
* Improve custom Nightwatch assertion comment readability Standardize capitalization, punctuation Use common language Reduce word count * Clarify elementCount arguments Before this commit the term `selector` was used for two separate arguments in two separate scopes. Rename the function passed to the browser so the developer understands that these are two arguments/two scopes/not the same value.
1 parent d6ba474 commit 5cc2f3b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

template/test/e2e/custom-assertions/elementCount.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// A custom Nightwatch assertion.
2-
// the name of the method is the filename.
3-
// can be used in tests like this:
2+
// The assertion name is the filename.
3+
// Example usage:
44
//
55
// browser.assert.elementCount(selector, count)
66
//
7-
// for how to write custom assertions see
7+
// For more information on custom assertions see:
88
// http://nightwatchjs.org/guide#writing-custom-assertions
9+
910
exports.assertion = function (selector, count) {
1011
this.message = 'Testing if element <' + selector + '> has count: ' + count{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
1112
this.expected = count{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
@@ -17,8 +18,8 @@ exports.assertion = function (selector, count) {
1718
}
1819
this.command = function (cb) {
1920
var self = this{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
20-
return this.api.execute(function (selector) {
21-
return document.querySelectorAll(selector).length{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
21+
return this.api.execute(function (selectorToCount) {
22+
return document.querySelectorAll(selectorToCount).length{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
2223
}, [selector], function (res) {
2324
cb.call(self, res){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
2425
}){{#if_eq lintConfig "airbnb"}};{{/if_eq}}

0 commit comments

Comments
 (0)