turning nightwatch.js test (using jquery function) into custom assertion or command -
i running jquery function many times through test suite in order validate whether elements visible in viewport (nightwatch's current commands visible, present, etc not factor in). seems valuable have reusable command or assertion, fighting uphill battle understand how translate current code new reusable code, , have spent many hours trying different things. i have other custom commands work well, not work on validating result of function, perform repeatable commands. leads me believe should custom assertion? documentation on custom assertions sparse, , has not helped me in piecing own custom assertion. this run in test files: browser.execute(function () { $.fn.isonscreen = function(){ var win = $(window); var viewport = { top : win.scrolltop(), left : win.scrollleft() }; viewport.right = viewport.left + win.width(); viewport.bottom = viewport.top + win.height(); var bounds = this.offset(); ...