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

    prehistoric-oxygen-77880

    12/15/2022, 1:12 PM
    Hello im trying to get a component test working , im using vue and their inject and provide. My components gets a service injected, how can i mock this in my component test. Vue3 / Vite
  • s

    straight-microphone-66008

    12/15/2022, 1:16 PM
    yes
  • t

    thankful-wire-37848

    12/15/2022, 1:34 PM
    Could you provide a bit of pseudo-html that clarifies the structure and point out which node you want to
    cy.get(...)
    ?
  • t

    thankful-wire-37848

    12/15/2022, 1:35 PM
    Maybe better to post this in the #755921440359841852 channel.
  • m

    millions-scientist-9990

    12/15/2022, 1:48 PM
    @thankful-wire-37848 I want a cy.get(something).find('a identifyer') But then click on a other sub object from the get and not within the find query
  • f

    fresh-doctor-14925

    12/15/2022, 1:54 PM
    Something like
    Copy code
    cy.get(parent)
      .within(() => {
        cy.get(child1)
        cy.get(child2).click
    })
  • m

    millions-scientist-9990

    12/15/2022, 1:56 PM
    I'm new to cypress but that looks wrong to me
  • f

    fresh-doctor-14925

    12/15/2022, 2:00 PM
    I've been using Cypress for 3 years. It's a perfectly valid way of approaching the problem you laid out https://docs.cypress.io/api/commands/within
  • m

    millions-scientist-9990

    12/15/2022, 2:14 PM
    So the get will be checked on child1 property and does not click or fail when a other parent does not have that child attribute?
  • f

    fresh-doctor-14925

    12/15/2022, 2:15 PM
    I don't understand what you're asking. I suggest you take a look at the
    within()
    docs, as I think it's what you need based on your earlier comment
  • m

    millions-scientist-9990

    12/15/2022, 2:16 PM
    I can only search on child1 i need to click on child2
  • f

    fresh-doctor-14925

    12/15/2022, 2:20 PM
    And if they're both within the same parent, you'll be able to do that using
    cy.within()
  • m

    millions-scientist-9990

    12/15/2022, 2:39 PM
    Oke i will take a look at it tomottow thank you
  • g

    gentle-school-70464

    12/15/2022, 3:15 PM
    Hey, do you have load testing framework also?
  • l

    limited-barista-33480

    12/15/2022, 5:12 PM
    Hello team, who can help me to know how I can execute a JavaScript code within the cypress code, that is, I have a test automation already built and I want that when it is executed, a JavaScript code is also executed?
  • a

    adorable-smartphone-87280

    12/15/2022, 5:19 PM
    Maybe take a look at
    cy.task()
    ? https://docs.cypress.io/api/commands/task
  • g

    gray-kilobyte-89541

    12/15/2022, 5:27 PM
    Cypress tests already run in the browser, so ... just execute it
  • h

    hundreds-rainbow-52802

    12/15/2022, 6:36 PM
    Hey Folks, I am trying to reach out a request that only appears as 302 HTTPStatus code, I made this code, but the intercept did not get nothing: it.only('Trying to get console request', () => { let errorUrl: String cy.visit(
    ${url}
    ) cy.intercept( { method: 'GET', path: '.*/\checkoutshopper.*' }).as('getMethod') cy.get('[value="authorised"]').click() cy.wait( '@getMethod').then(inter => { cy.log(JSON.stringify(inter)) console.log(JSON.stringify(inter)) }) cy.end() }); This is the request that I get: GET /checkoutshopper/services/PaymentIncomingRedirect/v1/localPaymentMethod?merchantAccount= Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 Accept-Encoding: gzip, deflate, br Accept-Language: en-US,en;q=0.9 Cache-Control: max-age=0 Connection: keep-alive Cookie: __cypress.initial=true Host: checkoutshopper-test.adyen.com Referer: https://test.adyen.com/ Sec-Fetch-Dest: iframe Sec-Fetch-Mode: navigate Sec-Fetch-Site: same-site Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.46 sec-ch-ua: "Not?A_Brand";v="8", "Chromium";v="108", "Microsoft Edge";v="108" sec-ch-ua-mobile: ?0 sec-ch-ua-platform: "Windows" This is the response: HTTP/1.1 302 Found traceparent: 00-35052b34c35923c9b9ff2fd033713f3f-fb5db89a22c2b58e-01 pspreference: NQ9QKBJVJQRXGN82 Location: mobileapp://3ds1_return?payload=Ab02b4c Content-Type: text/html; charset=utf-8 date: Thu, 15 Dec 2022 14:16:03 GMT Set-Cookie: __cypress.initial=true; Domain=adyen.com; Path=/ Vary: Accept, Accept-Encoding Content-Encoding: gzip Connection: keep-alive Keep-Alive: timeout=5 Transfer-Encoding: chunked
    f
    • 2
    • 3
  • f

    fresh-doctor-14925

    12/15/2022, 6:50 PM
    Hey Folks
  • k

    kind-photographer-81911

    12/15/2022, 7:57 PM
    Does anyone have any documentation on how to change the variables sent to a graphql request using alias Mutation. I have this so far:
    Copy code
    cy.intercept('POST', '/graphql', (req) => {
          const { body } = req
          if (hasOperationName(req, 'ChangeResidentOnboardingAddress')) {
            // Declare the alias from the initial intercept in the beforeEach
            req.alias = 'gqlChangeResidentOnboardingAddressQuery'
            // Set req.fixture or use req.reply to modify portions of the response
            }
         })
    And I've noted that when I do a @wait in my test for the alias, Cypress does seem to execute that correctly, but now that I need to modify the intercept, all the documentation i can find on req.fixture assumes the fixture is the response body, not the request body. I don't see anything on how to set the request variables The call my code is intercepting looks like this:
    Copy code
    {
      "operationName": "ChangeResidentOnboardingAddress",
      "variables": {
        "input": {
          "address": {
            "unit": "5"
          }
        }
      },
      "query": "mutation ChangeResidentOnboardingAddress($input: ChangeResidentOnboardingAddressInput!) {\n  changeResidentOnboardingAddress(input: $input) {\n    resident {\n      id\n      toAddress {\n        unit\n        __typename\n      }\n      __typename\n    }\n    __typename\n  }\n}\n"
    }
    but i need it to look like this:
    Copy code
    {
      "operationName": "ChangeResidentOnboardingAddress",
      "variables": {
        "input": {
          "address": {
            "unit": "5"
          }
         residentId: "14370228"
        }
      },
    *not sure if the query changes to reflect this
    residentId is a required field
  • b

    bitter-fountain-36713

    12/15/2022, 9:06 PM
    You have
    body
    from the
    req
    . Have you tried adding
    residentId
    to req.body?
  • k

    kind-photographer-81911

    12/15/2022, 9:07 PM
    So this actually seems to update the body. if i look at the results of console.log, there is a resident id. But when I look in the network tab, it's not in the graphql call.
    Copy code
    cy.intercept('POST', '/graphql', (req) => {
          if (hasOperationName(req, 'ChangeResidentOnboardingAddress')) {
            // Declare the alias from the initial intercept in the beforeEach
            req.alias = 'gqlChangeResidentOnboardingAddressQuery';
            req.body.variables.input.residentId='14271499'
            console.log('print out req', req);  
          }
        });
  • s

    straight-chef-47891

    12/15/2022, 10:54 PM
    Yes, i've updated everything to
    @cypress/grep
    ... gleb suggested using
    // @ts-ignore
    but I remember not having this issue when it was still with the old
    @cypress/grep
    and
    bahmutov/cypress-grep
  • g

    gray-kilobyte-89541

    12/16/2022, 1:12 AM
    Cypress moved the test config TS definition, I think the latest grep plugin addressed it
  • g

    gray-kilobyte-89541

    12/16/2022, 1:13 AM
    the network tab does not show the changed body, since it happens outside the browser. This is a good topic for a lesson in my network testing course, i don't remember if I had something like this. I think I explain it in this presentation https://slides.com/bahmutov/how-cy-intercept-works
  • s

    swift-kitchen-62493

    12/16/2022, 12:45 PM
    How from one bigger project which has 10 test cases, how to make each test be on a different branch? to turn them on separately?
  • t

    thousands-house-85089

    12/16/2022, 12:48 PM
    Branching is not meant for turning on tests independently. Branching is a fundamental part of a good version control system like Git or SVN.
  • t

    thousands-house-85089

    12/16/2022, 12:50 PM
    There's some info here about how you can specify which spec files to run, which sounds like more what you're after. You can do it via scripts in the package.json or just on the command line from your test runner. https://docs.cypress.io/guides/guides/command-line
  • t

    thousands-house-85089

    12/16/2022, 1:00 PM
    If your cypress repo is not under version control, then now might be a good time to learn about it 🙂
  • s

    swift-kitchen-62493

    12/16/2022, 1:50 PM
    thx, any idea how to deal with reCaptcha on register site? i have "googleCaptchaSiteKey" but can it help?
1...230231232...252Latest