These tools should only be used for testing since they change the entire interpreter state for simplicity. Use cy.invoke('removeattr', 'target') to get around new tab check out our example recipe where we use cy.invoke('removeattr', 'target') to test clicking on a link without opening in a new tab Your example only shows how to invoke a command from another click command, which is a rarely what you need to do when invoking a command from a program The question specifically says sometimes, calling it through the command line is fine, but sometime i would also like to call directly the function which hints that a solution invoked from.
WATCH