https://cypress.io logo
Join DiscordCommunities
Powered by
# e2e-testing
  • g

    gray-kilobyte-89541

    09/08/2022, 5:30 PM
    Yup, your getByData is incorrect. See my example, not single quotes but backticks to get JavaScript template literal strings (which insert the value of the
    selector
    variable into the string
  • l

    little-france-10142

    09/08/2022, 5:40 PM
    I'm having an issue setting my mailosaur API key in the
    config.ts
    . If I hard code the string
    MAILOSAUR_API_KEY: <"my-api-key">
    my tests work just fine. But I need to put all apikeys and such in a separate
    cypress.env.json
    . Referencing the mailosaur server ID in test code works just fine. When I hard code the apikey string the tests work just fine. To be super clear this works:
    Copy code
    env: {
      MAILOSAUR_API_KEY: "<my-api-key>",
    },
    I want this to work:
    Copy code
    env: {
      MAILOSAUR_API_KEY: Cypress.env("mailosaurApiKey"),
    },
    Or this:
    Copy code
    env: {
      MAILOSAUR_API_KEY: `${Cypress.env("mailosaurApiKey")}`,
    },
    But the last two do not work.
    • 1
    • 4
  • m

    melodic-ocean-83158

    09/08/2022, 5:57 PM
    This happens because the configuration file is executed before "cypress" is running. So the command "Cypress.env" has no way to work...
  • m

    melodic-ocean-83158

    09/08/2022, 5:59 PM
    Change the location from where Mailosaur looks for API Keys directly to the ENV file. Or set these values ​​in the Config file directly from the command line or action
  • l

    little-france-10142

    09/08/2022, 5:59 PM
    Of course. So maybe it makes sense to define the ApiKey somewhere else? Like the
    e2e.ts
    in support?
  • m

    melodic-ocean-83158

    09/08/2022, 6:03 PM
    Search for Keys directly in cypress.env.json.
  • l

    little-france-10142

    09/08/2022, 6:07 PM
    I just figured it out. I had
    "mailosaurApiKey":
    in my
    cypress.env.json
    I just needed to change it to
    "MAILOSAUR_API_KEY"
  • l

    little-france-10142

    09/08/2022, 6:08 PM
    You were correct though, I think Cypress was looking in the correct place, I had just named it incorrectly.
  • b

    broad-monkey-14727

    09/08/2022, 6:23 PM
    Thank you very much. Yes, that worked.
  • d

    dazzling-nest-77830

    09/08/2022, 7:26 PM
    Hi All, I’m working on a project using cypress version 9.7.0 and experimentalSessionAndOrigin set to true
  • d

    dazzling-nest-77830

    09/08/2022, 7:27 PM
    When I run a cypress test using the command line, all is passing however when I run it using the cypress GUI and chrome, it’s hanging up on visit command and never gets to the next line
  • d

    dazzling-nest-77830

    09/08/2022, 7:28 PM
    I suspect it may due to the log in process coming from a different origin, however, the configuration update to enable CORS should take care of that
  • d

    dazzling-nest-77830

    09/08/2022, 7:28 PM
    Also, again, I’m not getting this error when running the same test in command line
  • d

    dazzling-nest-77830

    09/08/2022, 7:28 PM
    Any ideas why this is?
  • d

    dazzling-nest-77830

    09/08/2022, 7:29 PM
    The login page is loading but the typing automation never happens
  • g

    green-diamond-44130

    09/08/2022, 10:21 PM
    Hi, I have a question if it's possible to delay request. I know it's possible to delay response with setDelay in req.continue() in cy.intercept(), but that's not what I need.
  • g

    gray-kilobyte-89541

    09/08/2022, 10:30 PM
    return a promise that resolves in N seconds? Covered in my "Spec 10" lesson at https://cypress.tips/courses/network-testing (paid course)
  • g

    green-diamond-44130

    09/08/2022, 10:32 PM
    that is also for delaying response, I need to delay request
  • g

    gray-kilobyte-89541

    09/09/2022, 1:23 AM
    I don't think that is correct, it delays the request, but if you can explain more, that would be helpful
  • g

    green-diamond-44130

    09/09/2022, 7:35 AM
    Bro, it delays response, request has already been sent to server ( I need to delay that sending request to server ) and when browser catches response it waits until promise is resolved.
  • a

    acceptable-hamburger-48790

    09/09/2022, 8:30 AM
    cy.wait(2000).then(() => { //send your request here }) - i can think of this
  • b

    bulky-account-48526

    09/09/2022, 9:20 AM
    Hi everybody I was using Cypress e2e feature and stumbled upon a strange behavior that I can’t explain. this is the test that I’m starting. It goes to google.de it looks if Germany is listed on the page and then conducts a search When the assertion succeeds in the test the afterEach is also performed without problems, but when the assertion in the test fails, the typing in the afterEach is not happening. When I pass force:true to the type command it works, but I want to understand why the input element is not actionable. describe('Visit google.de check if germany is listed and perform a search', () => { beforeEach('Visit google.de and accept cookies', () => { cy.visit('https://www.google.de/?hl=de'); cy.get('#L2AGLb').should('be.visible').click(); }) it('Check if Deutschland is listed as country - passing', () => { cy.get('.uU7dJb').should('be.visible').should('have.text', 'Deutschland'); }) it.skip('Check if Deutschland is listed as country - failing', () => { cy.get('.uU7dJb').should('be.visible').should('have.text', 'Deutschland1'); }) afterEach('Perform search', () => { cy.get('input[name="q"]').should('be.visible').type('test{enter}'); // cy.get('input[name="q"]').should('be.visible').type('test{enter}', {force: true}); cy.url().should('contain', 'search?q='); }) })
  • b

    bulky-account-48526

    09/09/2022, 9:27 AM
    sorry for the not very professional example... I just wanted to recreate the problem that I have with an intern UI on a website that everyone can access
  • g

    gray-kilobyte-89541

    09/09/2022, 10:30 AM
    ok, so I was right, my lesson from the paid course specifically delays the request, not the response. And how simple it is will surprise you 🙂 https://github.com/bahmutov/fastify-example-tests/blob/main/cypress/integration/spec10.js
  • t

    tall-house-95834

    09/09/2022, 10:58 AM
    Hello everyone, when i am trying to read the file from fixture it is taking 20 mins to read that file,cy.readFile also taking the same time, is there any way I can read that file faster like under 5 mins?
  • n

    nutritious-army-46708

    09/09/2022, 2:46 PM
    I need to write a test about "buy a course". Now the problem is: after runninig successfully, the account(email address) will be recorded "already bought the course". How can I make the test run successfully multitimes?
  • g

    gray-kilobyte-89541

    09/09/2022, 3:01 PM
    seems like someone needs to control the data for the test
  • n

    nutritious-army-46708

    09/09/2022, 3:05 PM
    got it! How about create multiple email address automatically in cypress?
  • a

    acceptable-hamburger-48790

    09/09/2022, 4:08 PM
    https://github.com/Clebiez/cypress-maildev
  • n

    nutritious-army-46708

    09/09/2022, 4:16 PM
    Could the cypress-maildev create new email address when running the test?
1...9899100...192Latest