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

    white-raincoat-83199

    08/18/2022, 11:14 AM
    Here's my code:
    Copy code
    // test.cy.ts
    beforeEach(() => {
        cy.wait(300);
    });
    afterEach(() => {
        cy.wait(100);
    });
    
    describe('Test ', () => {
      it('Go to homepage ', () => {
        cy.visit('/');
      });
    
      it('Login ', () => {
        login();
      });
    
      it('Profile ', () => {
        profile();
      });
    })
    After finish test with error, I check cookie that save logged user info, it isn't exsist
  • b

    blue-battery-71202

    08/18/2022, 11:16 AM
    Copy code
    ts
    beforeEach(() => {
        cy.wait(300);
     cy.session('login', () => {
      login();
     });
    });
    
    afterEach(() => {
        cy.wait(100);
    });
    
    describe('Test ', () => {
      it('Go to homepage ', () => {
        cy.visit('/');
      });
    
      it('Profile ', () => {
        profile();
      });
    })
  • b

    blue-battery-71202

    08/18/2022, 11:17 AM
    this way it should work. the
    'login'
    is an ID for that particular session. Every time you call cy.session with the same ID you have to have the same content inside of it, but don't worry, it won't call twice, only once in the cypress lifetime. So first time it will login properly (clicking, anything u have there) then it just restores the cookies, and storage from that session, and by that it imitates a "login"
  • r

    red-toothbrush-22589

    08/18/2022, 11:21 AM
    Hey, How can i check that by clicking outside a pop out maeesage on the screen i get back to the fmain page?
  • b

    blue-battery-71202

    08/18/2022, 11:23 AM
    cy.url
    will yield the current URL. then you can check with .contains()
  • m

    microscopic-crowd-9149

    08/18/2022, 12:30 PM
    Hi friends - i am working on some test cases where system reidrect cypress to another url & new URL loading perfectly but because of some reason cypress " waiting for new page to load --" but page loading perfectly ( no idea how to stop this ) i am adding page view srouce screenshot too
  • p

    purple-receptionist-35308

    08/18/2022, 12:39 PM
    Hello All, Could you please help me as I need to change browser language to be french for some test cases using Cypress but it doesn't work when using below script because there is automatic redirect to the original URL which has the default browser language(english) onBeforeLoad: (window, ...args) => { Object.defineProperty(window.navigator, 'language', { value: 'en-GB' }); Object.defineProperty(window.navigator, 'languages', ['en-GB']);
  • s

    sparse-piano-30763

    08/18/2022, 2:35 PM
    Any ideas about it folks? 😊
  • f

    fancy-dog-10840

    08/18/2022, 3:02 PM
    Hi All I recently upgraded to the the
  • f

    flaky-beach-50459

    08/18/2022, 5:16 PM
    hi, is it possible to do a cypress testing on a react-native non-expo application?
  • b

    brief-restaurant-78755

    08/18/2022, 8:39 PM
    Hi Everyone, I have a weird issue testing an element, it is a search field for equipment. If I manually in the QA env. type something I get a drop down menu with the options I have but when I run my test in cypress that dropdown comes out empty, and I dont know why!! if I type in cypress on that element then it displays the list of options. Any suggestion will be kindly appreciated.
  • f

    fresh-nail-30646

    08/18/2022, 8:51 PM
    Hey All, Is there a way to store helper functions in their own package, then import them into
    commands.js
    and add them as custom commands? I thought I had done it, but I keep getting errors.
  • f

    fast-artist-45202

    08/18/2022, 9:21 PM
    Hi Everyone I have a weird issue testing
  • f

    fast-napkin-28259

    08/19/2022, 8:00 AM
    Hey guys!
    cy.get('div').then((el) => el.index())
    returns a
    Chainable<number>
    , but how can I extract the number?
  • h

    high-restaurant-93761

    08/19/2022, 8:22 AM
    Hey all, we've got Cypress working just fine when ran locally with e2e testing on our Nuxt JS project. However, when we try to get it working in CI (Github Actions) we can't get it to work. We keep getting the following error:
    Copy code
    CypressError: Timed out retrying after 4000ms: `cy.its()` errored because the property: `$nuxt` does not exist on your subject.
  • h

    high-restaurant-93761

    08/19/2022, 8:23 AM
    Has anyone encountered something similar? I've tried using the official github action and writing a custom action to do it. I've ran a curl to ensure that the server is up and running before the cypress test is ran so we don't see why this would happen. Any help would be appreciated!
  • p

    polite-animal-57579

    08/19/2022, 10:26 AM
    Hey everyone, i ran into an issue where every one of my test cases freezes after the first .click(), not showing any errors or anything. A colleague of mine tried to run the tests himself and they seem to be working correctly. Any ideas on what could be causing this?
  • a

    acceptable-hamburger-48790

    08/19/2022, 11:13 AM
    Is it the test case that freeze or the application ? Also check the resource usage during the test execution, if its anything to do with system
  • l

    lemon-toothbrush-55306

    08/19/2022, 11:18 AM
    Hello I have a problem, I have my component which looks like this:
    Copy code
    js
    <Tooltip label={t('words.unlink')} hasArrow>
                  <IconButton
                    data-test-id={`unlink-token-${tokenId}`}
                    icon={<BiTrash />}
                    size="sm"
                    colorScheme="red"
                    variant="outline"
                    onClick={openRemove}
                  />
                </Tooltip>
    And my test:
    Copy code
    js
    it('Disassociate FT', () => {
        cy.contains(accountId).click({ force: true });
        cy.get('[placeholder="Escribe tu contraseña"]').type(defaultPass);
        cy.contains('Continuar', { timeout: 12000 }).click();
        cy.getBySel('unlink-token-0.0.2276691').click({force:true});
        cy.getBySel('button-portal-footer-right', { timeout: 4000 }).click();
      });
    When I inspect the element has the correct property but Cypress is telling me:
    Copy code
    js
    Syntax error, unrecognized expression: [data-test-id=unlink-token-0.0.2276691]
  • l

    lemon-toothbrush-55306

    08/19/2022, 11:18 AM
    How can I fix this?
  • a

    acceptable-hamburger-48790

    08/19/2022, 11:22 AM
    Can you share how your getBySel command looks like
  • l

    lemon-toothbrush-55306

    08/19/2022, 11:28 AM
    Copy code
    js
    Cypress.Commands.add('getBySel', (selector, ...args) => {
      return cy.get(`[data-test-id=${selector}]`, ...args);
    });
  • a

    acceptable-hamburger-48790

    08/19/2022, 12:24 PM
    https://docs.cypress.io/faq/questions/using-cypress-faq#How-do-I-use-special-characters-with-cy-get this might help you
  • g

    glamorous-country-57678

    08/19/2022, 1:52 PM
    Is there a reason why a request would continually be sent even after the test ends? I do have conditional logic in the request being sent contained in a
    cy.intercept()
    . The full intercept is here:
    Copy code
    cy.intercept(`${ethProvider}*`, (req) => {
                // conditonal logic to return different responses based on the request url
                console.log(req.body)
                const { method, params, id } = req.body
                if (method === 'eth_chainId') {
                    req.reply({
                        body: {
                            id: 1,
                            jsonrpc: '2.0',
                            result: '0x111111',
                        },
                    })
                } else if (
                    method === 'eth_call' &&
                    params[0]?.data === '0x79502c55'
                ) {
                    req.reply({
                        body: {
                            id,
                            jsonrpc: '2.0',
                            result:
                                '0x' +
                                Array(10 * 64)
                                    .fill(0)
                                    .map((_, i) => (i % 64 === 63 ? 1 : 0))
                                    .join(''),
                        },
                    })
                } else if (method === 'eth_call') {
                    // other uint256 retrievals
                    req.reply({
                        body: {
                            id,
                            jsonrpc: '2.0',
                            result: '0x0000000000000000000000000000000000000000000000000000000000000001',
                        },
                    })
                } else {
                    req.reply({
                        body: { test: 'test' },
                    })
                }
            }).as('ethProvider')
    I did read the docs on Conditional Testing (https://docs.cypress.io/guides/core-concepts/conditional-testing#:~:text=The%20problem%20is,overcome%20these%20problems...) but want to know if this is the reason requests are thrown like this.
  • m

    magnificent-finland-58048

    08/19/2022, 2:22 PM
    what should happen is like this let's say you have retries = 2 1st round: - fail (retry) - fail (retry) - fail (retry) then the whole CI fails then you manually retry the execution again, this time it will execute the entiire suite that's normal behavior
  • m

    magnificent-finland-58048

    08/19/2022, 2:22 PM
    if I got u right
  • s

    shy-accountant-52090

    08/19/2022, 3:53 PM
    Hi All. I have written e2e cypress automation tests with BDD cucumber framework on storybook to test a component. Now I'm trying to get a code coverage report for my tests. My test report says Statements 0%, Functions 100%, branches, 0% lines 0%. I would like to know why I'm not getting proper report. Don't know where/what is the mistake, if tests or in configuring code coverage🤨 Can any one please help me on this 😫🙏
  • i

    important-nest-99734

    08/19/2022, 4:08 PM
    Have you followed this guide? https://docs.cypress.io/guides/tooling/code-coverage
  • s

    stale-ambulance-12910

    08/19/2022, 8:19 PM
    I'm using Next.js and have just setup cypress this week. I've got a couple full flows working, but now I'm wondering if there's a way to mock
    getServerSideProps
    ? I found a guide, https://glebbahmutov.com/blog/mock-network-from-server/, but it seems to be outdated and not encouraged.
  • l

    little-france-10142

    08/19/2022, 8:42 PM
    Hello folks. It's been a while. I am trying to setup Mailosaur with Cypress. I've installed the plugin, as well as the Typescript plugin. I followed https://mailosaur.com/docs/frameworks-and-tools/cypress/ however I'm getting TS errors surrounding the
    message
    object returned from
    cy.mailosaurGetMessage
    . I can't seem to tell TS that it's going to get an object. It seems hell bent on it being a
    string | undefined
    . Can anyone help me with this?
    • 1
    • 1
1...848586...192Latest