1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-27 10:19:59 +00:00
mobilizon/js/tests/e2e/custom-assertions/elementCount.js
Thomas Citharel cf0cbc8bde
Move folder
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2018-06-06 18:14:05 +02:00

19 lines
650 B
JavaScript

// A custom Nightwatch assertion.
// The assertion name is the filename.
// Example usage:
//
// browser.assert.elementCount(selector, count)
//
// For more information on custom assertions see:
// http://nightwatchjs.org/guide#writing-custom-assertions
exports.assertion = function elementCount(selector, count) {
this.message = `Testing if element <${selector}> has count: ${count}`;
this.expected = count;
this.pass = val => val === count;
this.value = res => res.value;
function evaluator(_selector) {
return document.querySelectorAll(_selector).length;
}
this.command = cb => this.api.execute(evaluator, [selector], cb);
};