mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
26 lines
739 B
JavaScript
26 lines
739 B
JavaScript
// A custom Nightwatch assertion.
|
|
// the name of the method is the filename.
|
|
// can be used in tests like this:
|
|
//
|
|
// browser.assert.elementCount(selector, count)
|
|
//
|
|
// for how to write custom assertions see
|
|
// http://nightwatchjs.org/guide#writing-custom-assertions
|
|
exports.assertion = function (selector, count) {
|
|
this.message = `Testing if element <${selector}> has count: ${count}`;
|
|
this.expected = count;
|
|
this.pass = function (val) {
|
|
return val === this.expected;
|
|
};
|
|
this.value = function (res) {
|
|
return res.value;
|
|
};
|
|
this.command = function (cb) {
|
|
return this.api.execute((el) => {
|
|
return document.querySelectorAll(el).length;
|
|
}, [selector], (res) => {
|
|
cb.call(this, res);
|
|
});
|
|
};
|
|
};
|