I want to add logs to my custom commands in Cypress, for example
Cypress.Commands.add('shouldBeVisible',
{
prevSubject: 'element',
},
(subject) => {
var getText = cy.wrap(subject);
// cy.wrap(subject).invoke('val').then((element) =>{
// cy.log('element:: ' + cy.wrap(subject).get(subject))
// });
const log = Cypress.log({
name: "shouldBeVisible",
displayName: "SHOULD BE VISIBLE",
message: [
`️ (element: `+subject+` should be visible)`,
],
// @ts-ignore
autoEnd: false,
consoleProps() {
return subject
},
})
cy.wrap(subject).should('be.visible');
}
)
when I call it like this:
cy.visit('https://docs.cypress.io/guides/overview/why-cypress');
cy.get('.headerWrapper_tu51').shouldBeVisible();
I want it to log the calling function or calling element: