Hi Mark its showing me the following error loginP...
# help
a
Hi Mark its showing me the following error loginPage.loginPageHeaderText is not a function Because this error occurred during a before all hook we are skipping the remaining tests in the current suite: Test..
w
Oh gotcha, my bad I read too quickly - it's a getter. OK so I'd suggest simplifying this so you can find out what's going wrong. Does
cy.contains('.welcome-message > h1', 'Welcome')
work for you? Do you actually need a custom command for this? If you do still need a custom command, this might help understand what is happening: https://docs.cypress.io/guides/core-concepts/introduction-to-cypress#Subject-Management When you call
cy.get(element)
in your
shouldContain
command, it looks like
element
is return value of
loginPageHeaderText
, which is itself
cy.get(LOGIN_PAGE_HEADER_TEXT, {timeout: 140000})
. Which leads to a
cy.get(cy.get(...))
, when maybe what you want is to just chain off of the
element
parameter itself like
element.should('contain.text', text)
. I don't write a lot of code like this so my instincts might be a bit off.
a
Thanks a lot Mark. I totally for got the cy.get(element).contains('text') command. I dont need custom command for this
2 Views