Skip to content

Instantly share code, notes, and snippets.

@NicholasBoll
Last active November 18, 2020 12:28
Show Gist options
  • Save NicholasBoll/a6e86d697368971827106b6c9603f714 to your computer and use it in GitHub Desktop.
Save NicholasBoll/a6e86d697368971827106b6c9603f714 to your computer and use it in GitHub Desktop.
Adding Custom Cypress command
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
}
})
})
@ealdalu
Copy link

ealdalu commented Mar 21, 2019

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment