From 84a844ac06d7294c08137024a65216febd46f8b2 Mon Sep 17 00:00:00 2001 From: Rob Wierzbowski Date: Sun, 3 Sep 2017 15:08:10 -0400 Subject: [PATCH 1/2] Improve custom Nightwatch assertion comment readability Standardize capitalization, punctuation Use common language Reduce word count --- template/test/e2e/custom-assertions/elementCount.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/template/test/e2e/custom-assertions/elementCount.js b/template/test/e2e/custom-assertions/elementCount.js index c0103f9431..fc30c41877 100644 --- a/template/test/e2e/custom-assertions/elementCount.js +++ b/template/test/e2e/custom-assertions/elementCount.js @@ -1,11 +1,12 @@ // A custom Nightwatch assertion. -// the name of the method is the filename. -// can be used in tests like this: +// The assertion name is the filename. +// Example usage: // // browser.assert.elementCount(selector, count) // -// for how to write custom assertions see +// For more information on custom assertions see: // http://nightwatchjs.org/guide#writing-custom-assertions + exports.assertion = function (selector, count) { this.message = 'Testing if element <' + selector + '> has count: ' + count{{#if_eq lintConfig "airbnb"}};{{/if_eq}} this.expected = count{{#if_eq lintConfig "airbnb"}};{{/if_eq}} From c3a2181b1b13cfebd50083777f1cf8c327655deb Mon Sep 17 00:00:00 2001 From: Rob Wierzbowski Date: Sun, 3 Sep 2017 15:14:48 -0400 Subject: [PATCH 2/2] 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. --- template/test/e2e/custom-assertions/elementCount.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/test/e2e/custom-assertions/elementCount.js b/template/test/e2e/custom-assertions/elementCount.js index fc30c41877..972e9508ab 100644 --- a/template/test/e2e/custom-assertions/elementCount.js +++ b/template/test/e2e/custom-assertions/elementCount.js @@ -18,8 +18,8 @@ exports.assertion = function (selector, count) { } this.command = function (cb) { var self = this{{#if_eq lintConfig "airbnb"}};{{/if_eq}} - return this.api.execute(function (selector) { - return document.querySelectorAll(selector).length{{#if_eq lintConfig "airbnb"}};{{/if_eq}} + return this.api.execute(function (selectorToCount) { + return document.querySelectorAll(selectorToCount).length{{#if_eq lintConfig "airbnb"}};{{/if_eq}} }, [selector], function (res) { cb.call(self, res){{#if_eq lintConfig "airbnb"}};{{/if_eq}} }){{#if_eq lintConfig "airbnb"}};{{/if_eq}}