https://cypress.io logo
Join Discord
Powered by
# general-chat
  • c

    cuddly-thailand-33926

    06/19/2022, 4:34 PM
    I evaluate?
  • s

    silly-journalist-41771

    06/19/2022, 4:34 PM
    I've never utilised this method before
  • s

    silly-journalist-41771

    06/19/2022, 4:34 PM
    I'm pretty junior to cypress
  • s

    silly-journalist-41771

    06/19/2022, 4:34 PM
    Here the way I did it
  • s

    silly-journalist-41771

    06/19/2022, 4:35 PM
    Used commands class for my logic
  • s

    silly-journalist-41771

    06/19/2022, 4:35 PM
    And passed dynamic variables
  • s

    silly-journalist-41771

    06/19/2022, 4:35 PM
    Using. Should
  • c

    cuddly-thailand-33926

    06/19/2022, 4:45 PM
    I can see what you did and the methodology could come in handy but it's a bit far from human readable, If you make use of a pom You could have something like Const icecream = { VanillaTitle : () => cy.get(div[data-text=title]).eq(0) } Then in your spec file IcecreamsPage.VanillaTitle().should('have.text', 'Vanilla') You can make the assertion a custom command too and you'd then have IcecreamPage.VanillaTitle().Contains('Vanilla')
  • s

    silly-journalist-41771

    06/19/2022, 4:50 PM
    So I'd make a Pom file for my assertions?
  • s

    silly-journalist-41771

    06/19/2022, 4:51 PM
    Something like
  • s

    silly-journalist-41771

    06/19/2022, 4:51 PM
    BasketAssertions.js?
  • s

    silly-journalist-41771

    06/19/2022, 4:51 PM
    Then import to spec file?
  • s

    silly-journalist-41771

    06/19/2022, 4:56 PM
    Can you tell me more about the commands class? And. Contains
  • s

    silly-journalist-41771

    06/19/2022, 4:56 PM
    How does this make it reusable
  • c

    cuddly-thailand-33926

    06/19/2022, 5:03 PM
    Make a pom file for your gets Make another command.js file for your assertions Cypress.Commands.add('yourAssertionName', { prevSubject: true}, (subject) => { #example cy.wrap(subject).should(be.visibile) Return cy.wrap(subject) })
  • c

    cuddly-thailand-33926

    06/19/2022, 5:06 PM
    This way in your spec file you can have something like Lobby.Banner().IsVisible().HasPlayButtonOnHover()
  • s

    silly-journalist-41771

    06/19/2022, 5:23 PM
    I can't declare a variable if in the body of my export
  • s

    silly-journalist-41771

    06/19/2022, 5:23 PM
    In Pom @cuddly-thailand-33926
  • c

    cuddly-thailand-33926

    06/19/2022, 5:26 PM
    In your pom place your gets not your assertions
  • c

    cuddly-thailand-33926

    06/19/2022, 5:27 PM
    To create seperation of conserns
  • c

    cuddly-thailand-33926

    06/19/2022, 5:28 PM
    Pom's conserns is to get the component and name it
  • s

    silly-journalist-41771

    06/19/2022, 5:30 PM
    like this?
  • c

    cuddly-thailand-33926

    06/19/2022, 5:30 PM
    Hahaha yep
  • c

    cuddly-thailand-33926

    06/19/2022, 5:30 PM
    Export it
  • s

    silly-journalist-41771

    06/19/2022, 5:30 PM
    wait I can use POM like this
  • s

    silly-journalist-41771

    06/19/2022, 5:30 PM
    where do I add my export
  • s

    silly-journalist-41771

    06/19/2022, 5:30 PM
    wow
  • s

    silly-journalist-41771

    06/19/2022, 5:31 PM
    can't add like that
  • c

    cuddly-thailand-33926

    06/19/2022, 5:40 PM
    At the bottom after declaring the const, like for me I have Generic, Desktop and mobile So after const assertion = {} Write export default { assertion }
  • s

    silly-journalist-41771

    06/19/2022, 5:49 PM
    ahhh got you
1...525354...127Latest