https://cypress.io logo
Join Discord
Powered by
# e2e-testing
  • r

    refined-breakfast-53252

    05/05/2022, 11:50 PM
    Hello guys! okay? I would like to know if there is a plugin or framework that I can use in cypress to generate a report with html file. I've already tried using cypress's own report (free version) and one from Allure, but both don't generate an HTML file that I can open on another computer? At the moment the only one I managed to generate an html file that can be opened by other people and on other computers is mochawesome-reporter. Can someone help me?
  • a

    adorable-smartphone-87280

    05/06/2022, 3:43 AM
    mochawesome is what we used to use when we generated HTML reports. Now we just use the Cypress Dashboard.
  • l

    loud-vase-48777

    05/06/2022, 7:06 AM
    hi, there is a way to use a a utils class implemented by me in cy.origin? it seams have another scope and data between test and the cb cy.origin are not shared
  • m

    mammoth-fall-22117

    05/06/2022, 8:53 AM
    Hi, I am trying to write a piece of code that checks if button is enabled and if no then it clicks it.
    Copy code
    cy.get('[data-testid="button-id"]')
              .then('[data-testid="button-id"]') => {
            if (cy.get('[data-testid="button-id"]').should('be.enabled').false)
            {
              cy.get('[data-testid="button-switch-0"]').click()
            }
            else {}
          }
    I get this error and the code won't 'compile': "Expecting newline or semicolon". Any ideas what did I do wrong?
  • e

    echoing-painting-40909

    05/06/2022, 9:32 AM
    Hi, The problem is here :
    Copy code
    .then('[data-testid="button-id"]') =>
    .then
    expects a callback :
    Copy code
    .then(() => {})
    
    // wrong syntax
    .then() => {}
    The arrow is outside of then in your example Besides that, passing a string
    '[data-testid="button-id"]'
    won't work.
  • m

    mammoth-fall-22117

    05/06/2022, 9:50 AM
    Hello! Thank you for your reply. I read .then() documentation, fixed syntax and replaced string with $btn. This is how it looks now:
    Copy code
    cy.get('[data-testid="button-id"]').then(($btn) => {
            if (($btn).is('disabled')) {
              cy.get('[data-testid="button-id"]').click()
            }
            else {}
          })
    However, I have a problem with this IF condition now, because whatever I write there it never passes... (So if the button is disabled it never clicks it).
  • e

    echoing-painting-40909

    05/06/2022, 9:53 AM
    I would have to test it, but why would you want to click on a disabled button?
  • m

    mammoth-fall-22117

    05/06/2022, 9:55 AM
    This is a safety mechanism to avoid a flaky test. In my context, a certain business entity cannot be updated if it is disabled. I am running this against the QA environment where I don't know if the entity will be disabled or not. To prevent failure with the update test script I planned on checking if the entity is disabled. If yes => Enable and continue If no => Just continue
  • b

    brash-autumn-47936

    05/06/2022, 10:03 AM
    Hi, do we have any example of how to run the cypress test in parallel using code fresh? I am missing that in this document. https://github.com/cypress-io/cypress-example-kitchensink/tree/aabb10cc1bb9dee88e1bf28e0af5e9661427ee7a
  • e

    echoing-painting-40909

    05/06/2022, 10:33 AM
    I just tested, change
    disabled
    to
    :disabled
    :
    Copy code
    ts
    // from
    if (($btn).is('disabled')) {
    
    // to
    if (($btn).is(':disabled')) {
    m
    • 2
    • 1
  • m

    mammoth-fall-22117

    05/06/2022, 10:38 AM
    Worked! Thanks man ❤️
  • g

    gray-kilobyte-89541

    05/06/2022, 10:38 AM
    if you search my examples via https://cypress.tips/search you will find conditional testing examples https://glebbahmutov.com/cypress-examples/9.6.0/recipes/conditional-testing.html#click-a-button-if-not-disabled
  • m

    mammoth-fall-22117

    05/06/2022, 10:39 AM
    Thank you too! And by the way... thanks for the video on cy.origin() yesterday!
  • g

    gray-kilobyte-89541

    05/06/2022, 10:39 AM
    Sure, you are welcome
  • r

    refined-breakfast-53252

    05/06/2022, 11:44 AM
    @adorable-smartphone-87280 But Cypress doesn't generate an html, right?
  • r

    refined-breakfast-53252

    05/06/2022, 12:27 PM
    @adorable-smartphone-87280 Every time the test is run to generate the report-mochawesome-reporter. , the report folder is cleared. Is there a way to change this question?
  • a

    adorable-smartphone-87280

    05/06/2022, 3:23 PM
    No, Cypress does not generate native HTML reports.
  • a

    adorable-smartphone-87280

    05/06/2022, 3:24 PM
    I’m not sure on implementation because I don’t use mochawesome and replaced it as soon as I got here. I would assume that if you want them saved you’ll need some extra script. Are you running these tests in CI? You might need a reporting step in your workflows.
  • s

    sparse-cpu-70188

    05/06/2022, 4:40 PM
    @refined-breakfast-53252 Natively you don't get a n html report with Cyress, we have dashboard for that. Mochawesome reports are great and you have them with all the resources produced with Cypress (Snapshots, Text execution videos etc), if you also use them alongside cucumber as well. You can make certain adjustments to your cypress framework and have them configurable and stored as per your environment, maybe take a look https://medium.com/omnius/building-a-test-automation-framework-using-cypress-io-reporting-part-5-9fd4ac1da34d
  • r

    refined-breakfast-53252

    05/06/2022, 8:42 PM
    Which do you use?
  • a

    adorable-smartphone-87280

    05/06/2022, 9:52 PM
    Cypress Dashboard.
  • m

    mammoth-fall-22117

    05/07/2022, 6:06 AM
    Hye guys 😃 In the app that I am testing there is a quite exotic requirement when it comes to a decimal separator. Values like 1234 or 10000 are displayed 1'234 and 10'000... Same would be with millions 1000000 => 1'000'000. Now don't ask me why. Business is business 😅 My question is do you have any idea how to write assertion for such case. Example:
    Copy code
    cy.get('[id="some-input"]')
              .clear()
              .type(number)
            cy.get('[data-testid="update-button"]')
              .should('be.enabled')
              .click()
            cy.contains(number) >> Will fail because number is not 1234 but 1'234
  • m

    magnificent-finland-58048

    05/07/2022, 10:22 AM
    all you need is a regex pattern that will match contains support regex and is very powerful combine these 2 regex tools together to come up with the pattern https://regex-generator.olafneumann.org/?sampleText=Fri%20Feb%2011%202022&flags=i&onlyPatterns=false&matchWholeLine=true&selection= https://regex101.com/ then just feed that into cy.contains(/your-regex/)
  • m

    mammoth-fall-22117

    05/07/2022, 10:30 AM
    Why I haven't thought about this... Thanks 😉
  • g

    gray-kilobyte-89541

    05/07/2022, 12:40 PM
    if you know the value you could format the expected value yourself and use contains
  • m

    mammoth-fall-22117

    05/07/2022, 12:40 PM
    I know the value as I put it there one step before.
  • m

    mammoth-fall-22117

    05/07/2022, 12:41 PM
    Is there a "smart way" to insert this ' symbol between the hundreds, thousands, millions etc..?
  • g

    gray-kilobyte-89541

    05/07/2022, 1:15 PM
    is it the i18n by the browser? Or just
    '
    every 3 characters?
  • m

    mammoth-fall-22117

    05/07/2022, 1:19 PM
    Just ' every 3 characters
  • g

    gray-kilobyte-89541

    05/07/2022, 9:50 PM
    I recommend avoiding a regular expression then (since it only checks the format, but not the value), and just confirm the formatted value, see https://glebbahmutov.com/cypress-examples/9.6.0/recipes/check-number-format.html
1...394041...192Latest