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

    kind-photographer-81911

    12/20/2022, 3:33 PM
    My dev made a custom command and is using it all over the commands.ts file to update fixtures:
    Copy code
    const REGISTERED_INTERCEPT_HANDLERS: {
      // eslint-disable-next-line @typescript-eslint/ban-types
      [k: string]: Function[];
    } = {};
    
    const applyInterceptMutations = (type: string, response: any) =>
      (REGISTERED_INTERCEPT_HANDLERS[type] || []).reduce(
        (currentResponse, handler) =>
          produce((draft) => handler(draft.data, currentResponse) ?? draft)(
            currentResponse,
          ),
        response,
      );
    
    if (req.body.variables?.input?.residentId === '14259942') {
                req.reply(
                  applyInterceptMutations('resident', {
                    data: {
                      resident: {
                        resident: {
                          ...residentYardiSingleId.data.resident.resident,
                          invite: {
                            ...residentYardiSingleId.data.resident.resident.invite,
                            sourceMethod: 'manual',
                          },
                          status: 'UNCLAIMED',
                        },
                      },
                    },
                  }),
                );
                return;
              }
    Is there a way to update these graphql fixtures using cy.fixture? The cypress doc says to do this:
    Copy code
    // โœ… RESPOND WITH OBJECT
    cy.fixture('todo.json').then((todo) => {
      cy.intercept('GET', '/todos/1', { body: todo }).as('todo')
      // application requests the /todos/1 resource
      // the intercept replies with the initial object
    
      cy.wait('@todo').then(() => {
        // modify the response object
        todo.title = 'New data'
        // and override the intercept
        cy.intercept('GET', '/todos/1', { body: todo })
      })
    })
    but it doesn't work with graphql. The method signature call fo cy.intercept is for REST and I don't have a place to put the (req, res) and then update the res.body
  • f

    fresh-doctor-14925

    12/20/2022, 3:52 PM
    cy.fixture()
    is for getting the fixture for use in a spec. You could change parts of the fixture in the callback, however: It seems to me like the most straightforward approach would be for your dev to turn
    applyInterceptMutations
    into a function that can optionally take some parameters to tweak the graph query/mutation as you need
  • k

    kind-photographer-81911

    12/20/2022, 5:04 PM
    Shouldn't cypress have some sort of documentation for changing a graphql query though?
  • f

    fresh-doctor-14925

    12/20/2022, 5:20 PM
    From what I can see in the code above, you'll just be changing a string in JS. The Cypress docs shouldn't cover that That said, I'm just a bloke on the internet. I'm not affiliated with Cypress in any way. If you think you can make a strong case for the docs to include this, you can raise it as a feature request on the cypress repo
  • w

    wide-mechanic-91934

    12/20/2022, 5:49 PM
    Hello all, I'm in serious need of help! I'm getting the following error when I attempt to run my cypress scripts on chrome
  • w

    wide-mechanic-91934

    12/20/2022, 5:50 PM
    The setup is in our git repo, and my other developer team mates can run it just fine
  • b

    bumpy-monitor-32508

    12/20/2022, 6:15 PM
    Hi all idk if this is the place to ask sorry ๐Ÿ˜” but i've try to update from cypress 9.5.4 to the last version but when i try to run in docker i've got this error
    Copy code
    **libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
    [934181:1129/083805.379269:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported.**
    Do you know which drivers or configs need?
  • f

    fresh-doctor-14925

    12/20/2022, 6:55 PM
    !duplicate
  • n

    nutritious-analyst-96582

    12/20/2022, 6:55 PM
    Uh oh, It looks like you have posted the same question in multiple channels. Help us prevent spam by removing any duplicates of your questions, Thanks! ๐Ÿ˜€
  • g

    gray-kilobyte-89541

    12/20/2022, 7:23 PM
    my npm module "lazy-ass" strikes again ๐Ÿ™‚
  • a

    acceptable-bear-67664

    12/20/2022, 8:07 PM
    Hello! I would like some help if possible. I need to add some flags to the browser based on the spec file name, that will run next. Till Cypress 10.8.0 update it was possible to get spec file name through before:spec event and push some flags on before:browser:launch event. But changes in that update made before:spec event to fire after the browser one ๐Ÿฅฒ
  • m

    modern-air-62164

    12/20/2022, 8:11 PM
    Is it possible to use
    cy.task()
    in custom queries? I'm trying to add a custom query to retrieve a user from firebase:
    Copy code
    Cypress.Commands.addQuery(
      'getFirebaseUserByEmail',
      function getFirebaseUserByEmail(email) {
        return () => cy.task('getFirebaseUserByEmail', { email })
      }
    )
    The request has to be performed in a custom task since it runs in node and needs access to the admin SDK which isn't available in the client application. When I attempt to use the query, I receive:
    Copy code
    Timed out retrying after 4000ms: Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.
    
    The command that returned the promise was:
    
    > cy.getFirebaseUserByEmail()
    
    The cy command you invoked inside the promise was:
    
    > cy.task()
    
    Because Cypress commands are already promise-like, you don't need to wrap them or return your own promise.
    
    Cypress will resolve your command with whatever the final Cypress command yields.
    
    The reason this is an error instead of a warning is because Cypress internally queues commands serially whereas Promises execute as soon as they are invoked. Attempting to reconcile this would prevent Cypress from ever resolving.
    Thanks, all!
  • l

    limited-barista-33480

    12/20/2022, 9:45 PM
    I was running an automation test in which I added JavaScript code to execute a part of the functionality and I get this error. If, for example, I run that javascript code separately using the node command from the terminal, it works for me, but I want it to run from the test automation, not in another .js file. Do you know what I can do to make it run correctly from the cypress test. I also send you the code that I am implementing.
  • g

    gray-kilobyte-89541

    12/20/2022, 9:46 PM
    If you want to retry any cypress commands, as long as they don't fail, use http://github.com/bahmutov/cypress-recurse
  • g

    gray-kilobyte-89541

    12/20/2022, 9:47 PM
    Cypress tests run in the browser. You are trying to require a Node module that expects file system access, so that is not going to work. You can use https://on.cypress.io/task to run your npm code though
  • b

    brainy-airplane-28375

    12/21/2022, 4:39 AM
    Is there any way to automated/handle the ReCaptcha ?
  • f

    fresh-doctor-14925

    12/21/2022, 7:54 AM
    Hi, I answered this recently. If you search for Captcha on this Discord, you'll find the previous discussion
  • s

    swift-spoon-76449

    12/21/2022, 8:18 AM
    Hi all, I have to log in every morning via a Skype guest account through Chrome. I wanted to use Cypress to automate this process. However, something is blocking when calling Web.Skype. Do you guys have experience with similar situations? Thanks
  • p

    powerful-orange-86819

    12/21/2022, 8:46 AM
    Hi, I'm trying to implement flaky tests detection in cypress I read in the documentation that i should add retries to config, but i'm not sure if it should be under e2e: or inside the defineConfig({}) directly, has anyone activated test flakyness detection?
    Copy code
    json
    {
      "retries": {
        // Configure retry attempts for `cypress run`
        // Default is 0
        "runMode": 2
    }
  • f

    fresh-doctor-14925

    12/21/2022, 9:04 AM
    The answer is both, but the docs could be clearer about this. So I've got something like this:
    Copy code
    export default defineConfig({
      e2e: {
        retries: 2
      },
    })
  • p

    powerful-orange-86819

    12/21/2022, 9:06 AM
    thank you
  • w

    wide-mechanic-91934

    12/21/2022, 9:15 AM
    Any suggestions?
  • b

    bumpy-insurance-8581

    12/21/2022, 11:12 AM
    Hello, I have a problem. How can I set a cy.request() into a cy.task() ? I try to make cy.task(myTaskName, cy.request('GET', urlToRequest) but I got a converting circular structure to JSON that I donโ€™t get if i do cy.request('GET', urlToRequest).then(response)
    f
    • 2
    • 7
  • b

    bumpy-insurance-8581

    12/21/2022, 11:14 AM
    On my task looks like that :
    Copy code
    on('task', {
      requestReturnResponseStatus(response) {
          let respBody = response.body;
          respBody = formatRequestResponseBody(respBody);
          respBody = JSON.parse(respBody);
          return respBody.status;
      }
    });
  • g

    gray-kilobyte-89541

    12/21/2022, 11:43 AM
    I think you should check if you have the URL to visit in the
    cy.visit
    command
  • b

    bumpy-insurance-8581

    12/21/2022, 2:38 PM
    Is it possible that if a json is too big, that itโ€™s avoided from console.log() ?
  • f

    fresh-doctor-14925

    12/21/2022, 2:49 PM
    More likely you haven't successfully got the JSON
  • p

    proud-fall-12182

    12/21/2022, 3:14 PM
    Hi folks I'm trying to compile cypress from source on windows and then running it, have been facing a few issues. To do so, I've been performing the following steps 1) Cloning cypress repo, checking out to v12 2) Running
    yarn
    3) Running
    yarn build
    4) Running
    yarn binary-build
    5) Copying the contents of
    AppData\Local\Temp\cypress-build\win32\build\win-unpacked
    to
    AppData\Local\Cypress\Cache\12.0.0
    6) Running my project with the
    npx cypress run
    command as usual However, when doing so, cypress gets stuck and throws the error
    Timed out waiting for browser to connect
    (even though browser does get launched). Could someone guide me on where I'm going wrong?
  • w

    wide-mechanic-91934

    12/21/2022, 3:26 PM
    Found problem...had an env variabl called CYPRESS_PORT that was breaking everything -_______-
  • g

    gray-kilobyte-89541

    12/21/2022, 4:21 PM
    hehe !
1...235236237...252Latest