Last active
November 18, 2020 12:28
-
-
Save NicholasBoll/a6e86d697368971827106b6c9603f714 to your computer and use it in GitHub Desktop.
Adding Custom Cypress command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare namespace Cypress { | |
interface Chainable<Subject> { | |
myCustomCommand(username: string, password: string): Cypress.Chainable<Response> | |
} | |
} | |
Cypress.Commands.add('myCustomCommand', (username: string, password: string) => { | |
Cypress.log({ | |
name: 'loginByForm', | |
message: username + ' | ' + password | |
}) | |
return cy.request({ | |
method: 'POST', | |
url: '/login', | |
form: true, | |
body: { | |
username, | |
password | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
adding namespace block at top has great impact, such that the intelliSence recognizes custom commands. But when pressing ctrl+click on command in spec file, vscode navigates to the command in interface block, imagine there are many commands in same file, the programmer needs to manually navigate to actual command implementation. is there a way to let vscode navigate to actual command implementation ?