https://cypress.io logo
Join Discord
Powered by
# help
  • a

    aloof-lifeguard-45424

    05/11/2022, 10:44 AM
    Copy code
    Why you should do it regularly:
    https://github.com/browserslist/browserslist#browsers-data-updating
    GET /v1/buckets/main/collections/cfr/changeset?_expected=1651612261201 200 532.990 ms - -
    GET /v1/buckets/monitor/collections/changes/changeset?collection=whats-new-panel&bucket=main&_expected=0 200 553.418 ms - -
    GET /__cypress/tests?p=cypress%5Cintegration%5C1-getting-started%5Ctodo.spec.js 200 1660.547 ms - -
    GET /__cypress/tests?p=cypress%5Csupport%5Cindex.js 200 1685.197 ms - -
    GET /__cypress/runner/fonts/fa-regular-400.woff2 200 2.331 ms - 13600
    GET /v1/buckets/main/collections/whats-new-panel/changeset?_expected=1617030573137 200 545.862 ms - -
    GET /__cypress/runner/fonts/mulish-latin-700-normal.woff2 200 1.540 ms - 31176
    Error: read ECONNRESET
        at TCP.onStreamRead (node:internal/stream_base_commons:211:20)
     {
      errno: -4077,
      code: 'ECONNRESET',
      syscall: 'read'
    }
    Error: read ECONNRESET
        at TCP.onStreamRead (node:internal/stream_base_commons:211:20)
    
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! cypress-example-kitchensink@0.0.0-development cy:open: `cypress open`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the cypress-example-kitchensink@0.0.0-development cy:open script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\xxxxxxxxxxxxxxxxxxxxxx
  • c

    creamy-minister-50636

    05/11/2022, 1:19 PM
    We are trying to move from cypress-file-upload plug-in to using the built in cy.selectFile. However, tests are failing since the input element is not visible The plug-in worked out of the box with this, but the built in feature struggles. Is there a parameter or a setting that I'm missing?
  • m

    magnificent-finland-58048

    05/11/2022, 1:32 PM
    might want to use force: true
  • c

    creamy-minister-50636

    05/11/2022, 1:48 PM
    yeah...adding force: true resolved the issue
  • w

    witty-room-41457

    05/11/2022, 5:33 PM
    I'm really struggling to use
    cy.stub
    (https://docs.cypress.io/api/commands/stub) or
    cy.spy
    . I have a React app that calls a utility function to get data that I display in a component rendered on a certain page. I wanted to stub that utility function to return something else and ensure that the page renders that data (this is not a component test, but essentially seeding our environment with test data to then click around - we have a ton of tech debt at my startup, so there's unfortunately not an endpoint I can intercept to do this - it's all hard-coded in the frontend). I'm importing the utility function in my test and then have:
    Copy code
    import { classesUtil } from "<path_to_util>";
    
    describe("user can enroll", () => {
      it("ensure class is enrollable", () => {
         cy.spy(classesUtil, "injectCmsData");
         cy.visit("/page");
       })
    });
    When I visit this page, I see in the logs that I'm hitting this util, but when I expect the util to be called, it's not being hit (and the stub shows up in the cypress test runner, but doesn't show any number of calls. Can you use
    cy.stub
    and
    cy.spy
    on end-to-end tests, or just component tests? This wasn't very clear from the documentation
  • m

    magnificent-finland-58048

    05/11/2022, 6:36 PM
    Gleb has some real neat docs https://glebbahmutov.com/cypress-examples/9.6.0/commands/spies-stubs-clocks.html#cy-spy I had some knowledge gaps and filled them, recreating his stuff in this repo https://github.com/muratkeremozcan/cypressExamples/tree/master/spy-stub-practice/cypress/integration you can use them anywhere, ofc in component tests they will be used more often edit: with v9 there is an issue with mocking imported modules. I ran into it while wanting to stub feature flags at component level, but the issue applies everwhere https://github.com/muratkeremozcan/react-hooks-in-action-with-cypress/blob/main/src/components/Bookables/BookablesList.cy.js#L51
  • w

    witty-room-41457

    05/11/2022, 8:02 PM
    ahhh amazing, thank you @magnificent-finland-58048 - just upgraded to v9, so that's probably where my problem is
  • b

    brave-apartment-73149

    05/11/2022, 8:53 PM
    Hello, guys. Did anyone encounter that inside cy.origin closure cypress can not click through the page elements? Whereas selector playground finds elements which I want to click SO in case someone needs https://stackoverflow.com/questions/72211599/how-to-enforce-to-read-html-from-another-domain-inside-closure-of-the-cy-origin
  • r

    red-dentist-71156

    05/11/2022, 11:06 PM
    Hello everyone, I am looking to get help on how cypress studio record the commands. I have noticed for a web application I am working on after logging in and clicking on one of the navigation links, it stops recording the commands. any help on what may be causing this or how I can find the issue would be greatly appreciated.
  • a

    agreeable-electrician-45843

    05/11/2022, 11:36 PM
    Hi , when run my login script, after click login button , the new url loading is the same login url but with another session id when i see the logs after click login shows (new url) http://myweb.com/login.jsp;jsessionid=g0ssu1byd6gr1difebybjyz2h my test: beforeEach(() => { cy.visit('/'); }) const userName = "something"; const passwrd = ""something";"; it.only('login with valid user and password', () => { cy.get('#j_username', {timeout : 31500}).type(userName); cy.get('#j_password', {timeout : 31500}).type(passwrd); cy.contains('Login').click({force: true}); cy.get('#logout').should('be.visible'); cy.wait(2500); }); please help. Its similar problem than this one https://stackoverflow.com/questions/68710074/why-cypress-loads-login-page-again-instead-of-home-page but that solution didnt work for me due cy.origin problem. This script (my script ) works perfect in protractor dont understand why not in cypress
  • e

    elegant-dog-90839

    05/12/2022, 7:10 AM
    Hi, I am unsure if I found a bug or if I do something wrong here. cy.intercept is picking up the wrong url. This happens sometimes and I am not sure why: The request to
    wd-logs-arm
    is picked up as well beside the request I wanted to intercept -
    POST https://portal-dev.workdigital.de/api/v1/deposit
    . This leads to an odd behaivor where the
    wait('@').then((req))
    is returning the wrong request. Here is how I am registering the interceptor:
    Copy code
    js
            const url = /(.*)\/deposit(?!(.))/;
            cy.intercept(url, (req) => {
                req.continue((res) => {
                    if (forceSuccess) {
                        res.body.success = true;
                    } else if (forceFailure) {
                        res.body.success = false;
                    } else if (!res.body.success && shouldSucceed) {
                        expect(
                            res.body.success,
                            'It was not possible to change the the widget and it was expected that it would be possible'
                        ).to.be.true;
                    }
                    return res;
                });
            }).as(interceptName);
  • e

    echoing-painting-40909

    05/12/2022, 7:41 AM
    Hi from the screenshot we can't see the complete
    wd-logs-arm
    url. Check if it doesn't end with
    /deposit
  • e

    elegant-dog-90839

    05/12/2022, 8:19 AM
    no it does not
  • e

    elegant-dog-90839

    05/12/2022, 8:20 AM
    https://wd-logs-arm.apm.eu-central-1.aws.cloud.es.io/intake/v2/rum/events"
  • e

    elegant-dog-90839

    05/12/2022, 8:21 AM
    and there are actually more urls which are picked up by that interceptor
  • e

    elegant-dog-90839

    05/12/2022, 8:22 AM
    this is where I am waiting for the request
    Copy code
    js
                            cy.wait('@deposit').then((req) => {
                                console.log(req);
                                depositWidget.submitValidator(req);
                                cy.isRequestValid(req);
                                depositWidget.valueOfTheWidgetShouldBe(
                                    req.response.body.data.value
                                );
                            });
  • e

    elegant-dog-90839

    05/12/2022, 8:24 AM
    also now hovering over the side bar will trigger now more requests
  • e

    elegant-dog-90839

    05/12/2022, 9:26 AM
    here is a video you can see that in the end I am hovering over the left side and it triggers refreshes
  • c

    creamy-train-56346

    05/12/2022, 11:37 AM
    👋 I am trying to implement POM as best as I can. Important thing is not to mix logic with tests. It becomes really annoying and counter-productive in case of field validation. I have 3 fields with identical HTML structure and error message. I made something like this (first ss is from
    channelPage.ts
    , later from test file
    channelPage.spec.ts
    ):
  • c

    creamy-train-56346

    05/12/2022, 11:38 AM
    Naturally I would prefer not to repeat this code over and over again (DRY rule). So I came up with something like this:
  • c

    creamy-train-56346

    05/12/2022, 11:49 AM
    Unfortunatelly it doesn't work. Runner looks like this. As you can see only one field (the one pushed lastly) is being asserted. I have no clue why. During debugging attempts I found out that there are indeed 3 elements in
    elems
    array.
  • c

    creamy-train-56346

    05/12/2022, 11:50 AM
    When I try to invoke jQuery
    text
    method on each element only one (again the last one) return some string. Subsequent
    text
    attempt fails with following error:
  • c

    creamy-train-56346

    05/12/2022, 11:51 AM
    my question are: what did I miss? in case it's impossible to achieve this way, how can I follow DRY rule?
  • s

    sparse-insurance-21987

    05/12/2022, 1:06 PM
    I am still getting the above error in my project after doing given configuration
  • g

    gifted-boots-63851

    05/12/2022, 1:08 PM
    I think I can help you, I spent so much time on this do you want to have cucumber & uses some ts?
  • g

    gifted-boots-63851

    05/12/2022, 1:11 PM
    the first thing you should do it to use this package for cucumber:
    @badeball/cypress-cucumber-preprocessor
    (upgrade guide: https://github.com/badeball/cypress-cucumber-preprocessor/issues/689) and also this package for webpack
    @cypress/webpack-preprocessor
    then in your cypress plugin entry point (typically
    cypress/plugin/index.ts
    ):
    Copy code
    ts
    import webpack from '@cypress/webpack-preprocessor'
    
    export default (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => {
      on('file:preprocessor', webpack({
        webpackOptions: require('../webpack.config')(config),
      }))
    }
    where your webpack.config is the following:
    Copy code
    js
    module.exports = config => ({
      resolve: {
        extensions: ['.ts', '.js'],
      },
      module: {
        rules: [
          {
            test: /\.ts$/,
            exclude: [/node_modules/],
            use: [
              {
                loader: 'ts-loader',
                options: {
                  transpileOnly: true,
                },
              },
            ],
          },
          {
            test: /\.feature$/,
            use: [
              {
                loader: '@badeball/cypress-cucumber-preprocessor/webpack',
                options: config,
              },
            ],
          },
        ],
      },
    })
    and it should be good let me know if you dont understand something or still have an issue @sparse-insurance-21987
  • m

    magnificent-finland-58048

    05/12/2022, 1:39 PM
    try out the module pattern The debate on Page Object vs module pattern is really just Inheritance vs Composition. Inheritance (PO) is great for describing what something is; the page has x, y, z on it. Composition (module pattern) is great for describing what something does. Which one do you think best fits component based architecture, where components are the building blocks and get reused on pages? How about user flows? https://dev.to/muratkeremozcan/functional-test-patterns-with-cypress-27ed
  • s

    sparse-insurance-21987

    05/12/2022, 2:27 PM
    I want to use cucumber and import some default js class from node_modules package .
  • h

    hundreds-father-43644

    05/12/2022, 4:36 PM
    Hi people. Why sometimes cypress don't intercept requests in tests? I declare intercept list before visit page but sometimes wait appear before intercepts.
    Copy code
    describe('Edit coupon bad alerts', () => {
      const affiliatesUrl = Cypress.env('api_url') + Cypress.env('get_affiliates')
      const affiliateCategoriesUrl = Cypress.env('api_url') + Cypress.env('coupon_affiliate_categories')
      const getCoupom = Cypress.env('api_url') + "/coupons/385162-2"
    
      beforeEach(() => {
        cy.clearCache()
        cy.setFirebaseCookies()
        cy.intercept('GET', affiliatesUrl, { fixture: 'affiliate/good.response.json' }).as('affiliates')
        cy.intercept('GET', affiliateCategoriesUrl, { fixture: 'affiliate-categories/good.response.json' }).as('affiliateCategories')
        cy.intercept('GET', getCoupom, { fixture: 'coupon/coupon.json' }).as('coupon');
        cy.visit('http://localhost:3000/cupons/385162-2')
        cy.wait(['@coupon', '@affiliateCategories', '@affiliates'])
      })
    
      it('Should show error alert when edit Coupon failed', () => {
        cy.intercept('PATCH', getCoupom, { statusCode: 400 }).as('editCoupon');
    
        cy.get('[data-cy="coupon-id"]').type('TESTE123450192TESTE')
    
        cy.get('[data-cy="coupon-save-button"]').click()
        cy.get('[data-cy="snack-alert"]').invoke('text').should('eq', 'Ocorreu um erro inesperado!')
        cy.url().should('eq', 'http://localhost:3000/cupons/385162-2')
        cy.wait('@editCoupon', { timeout: 50000 })
      })
    })
  • r

    rapid-accountant-7361

    05/12/2022, 4:56 PM
    Hi everyone, I have setup a gitlab stage to run e2e tests as part of a the pipeline from the application repository once a deployment has succeeded to the the environment. I've setup cypress dashboard, but the run in cypress dashboard is only picking up the details from my cypress repo. There is a link to the gitlab pipeline that triggered the run, but what I really want to see is the name of the merge request from the application repo that triggered the run. Is that even possible?
1...626364...252Latest