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

    worried-lifeguard-15953

    11/15/2022, 11:29 PM
    Please see my original question. The challenge is to find the element type based on the result; not find a result based on element type.
  • e

    enough-truck-68085

    11/15/2022, 11:32 PM
    Nice find! Didn't know about
    localName
    but that seems to do the trick
  • w

    worried-lifeguard-15953

    11/15/2022, 11:32 PM
    Yeah, console output to the rescue.
  • g

    gray-kilobyte-89541

    11/16/2022, 12:23 AM
    Since you tagged me - use Kafra from the config / plugins file that runs in Node and call it as a task
  • f

    future-eye-56254

    11/16/2022, 1:29 AM
    Hi @gray-kilobyte-89541 @mysterious-belgium-25713 I tried just as you have suggested and I can see the console log printing the messages on the console but the task returns an error when called my cypress test -* "The task 'run' returned undefined. You must return a value, null, or a promise that resolves to a value or null to indicate that the task was handled.*" I am actually returning back to the function.
  • f

    future-eye-56254

    11/16/2022, 1:30 AM
    Copy code
    e2e: {
        setupNodeEvents(on, config) {
            on("task", {
    
                async run() {
                    let messages
                    await consumer.connect();
                    await consumer.subscribe({
                        topic,
                        fromBeginning: true //to be changed to false later to read only latest
                    });
                    await consumer.run({
                        eachMessage: async ({
                            topic,
                            partition,
                            message
                        }) => {
                            console.log({
                                topic,
                                partition,
                                offset: message.offset,
                                value: message.value.toString()
                            });
                            messages = message.value.tostring();
                        }
                    })
                    return messages //value returned to the consume function
                }
            });
        }
    }
  • f

    future-eye-56254

    11/16/2022, 1:32 AM
    My Cypress Test is
    Copy code
    it('test 1, () => {
      cy.task('run').then((data) => {
      cy.log(data);
    //or some assertions on the data
    })
    })
  • g

    gray-kilobyte-89541

    11/16/2022, 1:55 AM
    I doubt you return something, looking at your code
    Copy code
    await consumer.run({
                        eachMessage: async ({
                            topic,
                            partition,
                            message
                        }) => {
                            console.log({
                                topic,
                                partition,
                                offset: message.offset,
                                value: message.value.toString()
                            });
                            messages = message.value.tostring();
                        }
                    })
                    return messages //value returned to the consume function
    seems you await
    consumer.run
    BUT you never confirm that you have received any messages there, right? You provided a callback
    eachMessage
    , but how do you know that it has executed at least once? You simply return
    messages
    variable, but since it is set inside the
    eachMessage
    , and
    eachMessage
    has not run, then you return the
    undefined
    default value of the variable
    messages
  • g

    gentle-dinner-26394

    11/16/2022, 2:01 AM
    Can anyone tell me definitely how a cy.intercept handles a 302 redirect in the response. It's confusing following the logs... take the screenshot as an example. I'm waiting on an ajax POST (@recipeUpdate). It returns a 302 to GET the same url. I can see in the devtools network tab the POST 302 and the GET 200. The logs though show the POST as a 200 and then displays the GET seemingly AFTER the wait. So did it wait only for the POST, for the POST and the GET (and use the status code from the final request in the first request?) - hard to verify exactly what it's doing!
  • f

    future-eye-56254

    11/16/2022, 2:01 AM
    I can confirm that eachMessage has executed. The console log actually prints the output on the console console.log({ topic, partition, offset: message.offset, value: message.value.toString() });
  • f

    future-eye-56254

    11/16/2022, 3:01 AM
    I also tested console.log(messages) inside the run() which is the variable the messge is assigned to and can confim it gets printed too
  • f

    few-oyster-82478

    11/16/2022, 9:32 AM
    does parallelization flag work without Cypress Dashboard? (we have a Gitlab CI pipeline)
    Copy code
    parallel: 5
    script:
      ...
      - npx cypress run --parallel --browser chrome --group "UI - Chrome"
    https://docs.cypress.io/guides/continuous-integration/gitlab-ci#Worker-Jobs
  • m

    mysterious-belgium-25713

    11/16/2022, 10:12 AM
    No it will not work without the dashboard.
  • n

    narrow-cpu-2218

    11/16/2022, 10:27 AM
    Is there a way to use BeforeEach before each suite and not before each test?
  • m

    mysterious-belgium-25713

    11/16/2022, 10:32 AM
    Put a before each in your commands.js
  • m

    mysterious-belgium-25713

    11/16/2022, 10:32 AM
    But i dont know if that will also do before each all tests
  • n

    narrow-cpu-2218

    11/16/2022, 10:58 AM
    Nvm I realised my problem really is that I have a before inside the describe and I want beforeeach to happen before the before
  • f

    faint-thailand-67863

    11/16/2022, 11:09 AM
    Is it possible to wait until page is fully loaded to execute .should?
  • f

    few-oyster-82478

    11/16/2022, 11:15 AM
    I'm having a very slow first test execution with Cypress
    11.x
    , when I execute
    cypress open
    in local environment, it stays a long time showing
    loading tests
    animation, and this are the two requests that is making in the background:
    Copy code
    GET /__cypress/tests?p=cypress%5Csupport%5Ce2e.ts 200 349523.700 ms - -
    GET /__cypress/tests?p=cypress%5Ce2e%5Cup.feature 200 373655.954 ms - -
    (about 5 min each of these two GETs, before the page is loaded) The code so far is very simple:
    Copy code
    // up.feature
    Feature: Server is up
      Scenario: visiting the frontpage
        When I visit the frontpage
        Then I should see the auth form label
    Copy code
    // up.cy.ts
    import { Then, When } from '@badeball/cypress-cucumber-preprocessor';
    
    When('I visit the frontpage', () => {
      const url = String(Cypress.config().baseUrl);
      cy.visit(url);
    });
    
    Then('I should see the auth form label', () => {
      cy.findByRole('heading', {
        name: /log into your account/i,
      });
    });
    when executing the tests in local, I have the local environment already running with the
    baseUrl
    (
    http:localhost:9000
    in my case), maybe I'm misunderstanding how this works and cypress is somehow trying to start the project by itself? I'm using this config for `cypress.config.ts`: https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/examples/webpack-ts/cypress.config.ts
  • g

    gray-kilobyte-89541

    11/16/2022, 11:48 AM
    but it returns it before it gets executed I think
  • a

    acceptable-hamburger-48790

    11/16/2022, 12:30 PM
    You can intercept and wait for all the requests to be resolved
  • f

    faint-thailand-67863

    11/16/2022, 12:33 PM
    hmmm, it is the best way I guess right?
  • a

    acceptable-hamburger-48790

    11/16/2022, 12:48 PM
    Thats what i do as its reliable and gives confidence - Rather than just waiting for elements
  • b

    brash-tiger-52405

    11/16/2022, 2:31 PM
    Hello can anyone tell me where and what i have to change when i get the following error. I think the path should be cypress/fixtures/login-data/integration/cypressTestUser0.
  • c

    careful-tent-30457

    11/16/2022, 3:13 PM
    Hi, I need some help working with arrayBuffer and intercepts. so in our app we often get images from our API as
    octet-stream
    and we can get the strem data as arrayBuffers using Axios. so an example component looks like
    Copy code
    async function getFile(id) {
      const response = await axios.get(`/api/file/%{id}`, {responseType: 'arrayBuffer'});
      return response.data;
    }
    
    const Comp = (id) => {
      const { data } = useQuery(['file', id], () => fetchFile(id));
      const [dataUrl, dataUrl] = useState();
    
      useEffect(() => {
        if (!data) { return }
        const objectUrl = URL.createObjectURL(new Blob([data]));
        setDataUrl(objectUrl);
        return () => URL.revokeObjectURL(objectUrl);
      }, [data]); 
    ...
    so my issue is I cannot figure out how to get this code that works fine in dev/prod to work in cypress with an intercept.. I cannot seem to get the intercept to return same arrayBuffer data as get in dev/prod.. any assistance welcome.
  • g

    gray-kilobyte-89541

    11/16/2022, 3:21 PM
    There is an example like this in my https://cypress.tips/courses/network-testing (paid course)
  • c

    careful-tent-30457

    11/16/2022, 3:22 PM
    Thanks. Might have to pick up a license 😅
  • r

    red-gpu-23661

    11/16/2022, 4:53 PM
    Hi Guys, Im trying to connect sql server database using tedious and last version of cypress 10 (PS : earlier versions work perfectly !) I have followed all the recommendations from jennifer shehane : https://gist.github.com/jennifer-shehane/f498ce68b46425583fa72c8d945fe7bb But I get an error: cy.task('sqlServer') timed out after waiting 60000ms. And nothing happens! Any assistance welcome. Thanks in advance
  • r

    red-gpu-23661

    11/16/2022, 5:45 PM
    Im using the same config and the error still persists :
    cy.task('sqlServer') timed out after waiting 60000ms.Learn more
  • r

    red-smartphone-84750

    11/16/2022, 6:26 PM
    Hello there I got a problem in the following test:
    Copy code
    it("should the form be filled when the page is redirected", () => {
          cy.open("checkout", {
            checkout,
          })
          cy.findByText("Pagar").click()
          cy.wait("@checkout").intercept(
            "https://www.mercadopago.com/mla/checkout/start?pref_id=202809963-a2201f8d-11cb-443f-adf6-de5a42eed67d",
            req => {
              req.redirect("http://localhost:3000/checkout")
            }
          )
          cy.location().should(loc => {
            expect(loc.toString()).to.eq("http://localhost:3000/checkout")
          })
          cy.findAllByLabelText("Punto de venta 3 - Calle 1 123").should(
            "be.checked"
          )
        })
    Sometimes pass the last
    findAllByLabelText
    , sometimes does not exist. I tried using
    cy.location
    but it does not work well. How can I solve this situation?
1...206207208...252Latest