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

    bulky-sundown-74498

    07/16/2021, 4:13 PM
    My question would be: why do you run cypress in the
    /e2e
    working directory and if you could imagine listing it
  • u

    user

    07/16/2021, 4:14 PM
    Because Cypress container comes with directory structure and
    e2e
    is at the root level of that structure. Hence I'm mapping my
    /cypress
    directory to the
    e2e
    directory within the Cypress container.
  • u

    user

    07/16/2021, 4:29 PM
    According to this https://www.cypress.io/blog/2021/05/05/fast-end-to-end-browser-tests-using-cypress-and-gitlab-ci/ article
    cypress.json
    supposed to be on the same level with
    cypress
    directory. I have it that way and yet it throws error.
  • u

    user

    07/16/2021, 5:32 PM
    @User this
    docker run -v $PWD:/e2e -w /e2e --entrypoint=cypress --network tdd_default cypress/included:7.7.0 run
    command did the trick. But don't ask me why it works since I don't have
    e2e
    directory. That part is left mystery.
  • a

    ancient-wire-34126

    07/16/2021, 5:45 PM
    Is there a way to extend the cy interface automatically when adding commands?
  • a

    ancient-wire-34126

    07/16/2021, 5:51 PM
    Oh I found the recipe for it, nm
  • u

    user

    07/17/2021, 5:52 AM
    ?
  • u

    user

    07/17/2021, 12:02 PM
    Why Logout route fails when clicked by Cypress runner but is OK when I manually test the functionality ?
  • a

    ancient-wire-34126

    07/17/2021, 12:28 PM
    Looks like your logout route throws a 401? That's... ironic
  • u

    user

    07/17/2021, 12:43 PM
    I know right.
  • a

    ancient-wire-34126

    07/17/2021, 3:43 PM
    I would think that maybe a cookie isn't properly set or something? Depends a bit on how you (programatically) log in in Cypress
  • a

    ancient-wire-34126

    07/17/2021, 3:43 PM
    I usually try to compare the Cypress storage v.s a locally run version and see if there's anything missing
  • u

    user

    07/17/2021, 3:51 PM
    "Cypress storage" ? Are you saying Cypress has it own storage for keeping tokens and sensitive data ?
  • a

    ancient-wire-34126

    07/17/2021, 6:48 PM
    No it's just the browser, but I compare the browser Cypress uses to my local one at times. Esp. when it comes to authing it's important that the right data is actually stored
  • u

    user

    07/17/2021, 7:07 PM
    I checked. The token is being stored correctly.
  • u

    user

    07/17/2021, 7:12 PM
    Besides it's just an alphanumerical code.
  • a

    ancient-wire-34126

    07/17/2021, 8:27 PM
    Hm odd, anything in the network tab that looks off?
  • u

    user

    07/17/2021, 9:53 PM
    our app changes to often to truly do some E2E testing or component testing. So I decided to use it to check for performance with cypress-audit aka lighthouse. I generate a report but unable to figure out how I can pass a name for the report to generate from when i call cy.lighthouse(); plugin:
    Copy code
    const { lighthouse, pa11y, prepareAudit } = require('cypress-audit');
    const fs = require('fs');
    const ReportGenerator = require('lighthouse/report/report-generator');
    
    module.exports = (on, config) => {
      on('before:browser:launch', (browser, launchOptions) => {
    
        prepareAudit(launchOptions); 
        if (browser.name === 'chrome' && browser.isHeadless) {
          launchOptions.args.push('--disable-gpu');
          return launchOptions;
        }
      });
    
      on('task', {
        lighthouse: lighthouse((lighthouseReport) => { 
          fs.writeFileSync(`cypress/lhreport-${cy.location('pathname')}.html`, ReportGenerator.generateReport(lighthouseReport.lhr, 'html'));
        }),
        pa11y: pa11y(),
      });
    };
    My example test case:
    Copy code
    const customThresholds = {  
        performance: 0,
        accessibility: 0,
        seo: 0,
        'best-practices': 0,
        pwa: 0,
      };
    
      const desktopConfig = { 
        extends: 'lighthouse:default',
        formFactor: 'desktop',
        screenEmulation: {disabled: true}
      };
    
        it('Should load Dashboard', () => {
            cy.wait(500);
            cy.location('pathname', { timeout: 3000 }).should('eq', '/accounts/overview');
            cy.lighthouse(customThresholds, desktopConfig);
            cy.pa11y();
        });
  • u

    user

    07/17/2021, 9:55 PM
    so it generates a report and creates a file called lhreport.html but I would like it to generate a report called lhreport-.html for example lhreport-dashboard.html
  • u

    user

    07/18/2021, 9:38 AM
    I figured it out. My register route was creating the auth token from wrong data hence my logout route threw 401 when the token was used. Cypress was innocent on this. 🙂
  • a

    ancient-wire-34126

    07/18/2021, 12:46 PM
    👍
  • u

    user

    07/18/2021, 1:19 PM
    Based on this repo created by @bahmutov https://github.com/cypress-io/cypress-example-docker-compose/blob/master/e2e/cypress/integration/spec.js I can run tests with Cypress against containerized service by giving
    'baseUrl': 'http://<service><port>'
    and then specifying url by
    cy.visit('/')
    for root route. What if I want to navigate to
    "/something"
    ? I get status code 200 on
    "/"
    but getting 404 on others.
  • s

    steep-account-67575

    07/19/2021, 12:14 PM
    I'm seeing some weird issues with using
    @cypress/watch-preprocessor
    in GitHub actions. Simply requiring it is throwing this error:
    Copy code
    1) An uncaught error was detected outside of a test:
         SyntaxError: The following error originated from your test code, not from Cypress.
    
      > Cannot use import statement outside a module
    This is with Cypress 7.7.0, Chrome 91, Node 14.15.4. I think I eliminated all other factors by now and can get my build working by not using the watch preprocesser in GH actions.
  • u

    user

    07/19/2021, 2:19 PM
    I have been getting this message every time I run through my test. It is causing the loading spinner on the screen to infinitely run for some reason. This only occurs on cypress as it works as intended on a normal chrome browser. I think it has something to do with Ajax, but it's speculation at this point
  • a

    ancient-wire-34126

    07/19/2021, 3:34 PM
    How are you supposed to intercept and reply with a fixture if you're not allowed to either async/await or return from the intercept?
  • a

    ancient-wire-34126

    07/19/2021, 3:35 PM
    Copy code
    ts
      cy.intercept({ method: 'POST', url: 'https://cognito-idp.us-east-1.amazonaws.com' }, (req) => {
        const { body } = req
    
        if (body.AuthFlow && body.AuthFlow === 'CUSTOM_AUTH') {
          cy.fixture('cognito/email-valid').then(fixture => {
            return req.reply({ fixture })
          })
        }
      })
    This, for some reason, doesn't work and I have no clue how to get around it
  • a

    ancient-wire-34126

    07/19/2021, 3:49 PM
    Copy code
    The cy command you invoked inside the promise was:
    
    > cy.readFile()
    > I mean how is that a Promise?
  • a

    ancient-wire-34126

    07/19/2021, 3:50 PM
    it's just the handler function of
    cy.intercept
  • a

    ancient-wire-34126

    07/19/2021, 4:04 PM
    Copy code
    ts
      cy.intercept({ method: 'POST', url: 'https://cognito-idp.us-east-1.amazonaws.com' }, (req) => {
        const { body } = req
    
        if (body.AuthFlow && body.AuthFlow === 'CUSTOM_AUTH') {
          req.alias = 'customAuthValid'
          req.reply({ fixture: 'cognito/email-valid.json' })
        }
    
        if (body.ChallengeName && body.ChallengeName === 'CUSTOM_CHALLENGE') {
          req.alias = 'customChallengeValid'
          req.reply({ fixture: 'cognito/challenge-valid.json' })
        }
      })
    This works because... reasons
  • a

    ancient-wire-34126

    07/19/2021, 4:05 PM
    I have to say, the whole thennable part of Cypress is... not great. It's very unclear (to me) when you can write async stuff, and when you have to chain thens and when you can/can't use it in cypress internal commands
1...272829...252Latest