Here's a full Typescript Cypress project.
Encountering an error while trying to use the custom command below:
Usage:
cy.restGetUserId(userEmail).then(userId => {
//do something with userId
});
Custom command:
Cypress.Commands.add('restGetUserId', (userEmail) => {
expect(userEmail).to.not.equal(undefined);
cy.request({
//some request, works!
}).then((response) => {
cy.wrap(response.body.id);
});
});
Current documentation:
/**
* also works as a normal user
*
* @example cy.restGetUserId('<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1b6874767e5b7e767a727735787476">[email protected]</a>');
* @param userEmail - get the userId from this email
* @returns the id of the given email/user.
*/
restGetUserId(userEmail: string): string;
The error most likely lies in the documentation of this method. What is the best way to document this method properly, especially focusing on the return value?