The question is related to general js programming, but I'll use nightwatch.js as an example to elaborate