I'm using Cypress 9.5.3 and Typescript 4.5.
Is there a way to create custom commands hierarchically? As a result I'd like to type (as an example):
cy.loginAs.admin();
Currently I can only write a command:
cy.loginAsAdmin();
Also support from VSC is important for me.
EDIT 1
I'd like to use those nested commands like this:
cy.loginAs.admin();
cy.loginAs.operator();
cy.loginAs.user();
cy.loginAs('admin');orcy.loginAs('user');cy.asAdmin().login(). But your example is too trivial what wouldadmin()do but return the string "admin"? Does it need to check context in some way?