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

    mysterious-sandwich-43667

    07/15/2022, 7:52 PM
    Does anyone know the syntax for passing in an options object to cy.fixture? I want it to allow for empty files. Something like cy.fixture('file.o8d', {'allowEmpty': true})
  • f

    famous-restaurant-30435

    07/15/2022, 7:59 PM
    I’m not sure this makes sense. What is the goal you are trying to accomplish?
  • m

    mysterious-sandwich-43667

    07/15/2022, 8:01 PM
    allowEmpty exists according to the docs, but I see no syntax examples of how to set fixture options
  • m

    mysterious-sandwich-43667

    07/15/2022, 8:04 PM
    Upload test. Need to verify that uploading an empty file doesn't break the app. allowEmpty exists according to the docs, but I see no syntax examples of how to set fixture options
  • f

    famous-restaurant-30435

    07/15/2022, 9:43 PM
    Based on the docs, I dont think there is an allowEmpty config option for cy.fixture https://docs.cypress.io/api/commands/fixture#Arguments
  • f

    famous-restaurant-30435

    07/15/2022, 9:43 PM
    Are you sure you arent getting confused with this package? https://github.com/abramenal/cypress-file-upload/blob/main/README.md
  • m

    mysterious-sandwich-43667

    07/16/2022, 1:39 AM
    True. The error said "> given fixture file is empty. Please make sure you provide correct file or explicitly set "allowEmpty" to true" so I assumed it was the cy.fixture() call.
  • m

    mysterious-sandwich-43667

    07/16/2022, 1:40 AM
    Unfortunately, I still get the same error with: cy.getBySel('upload-button').attachFile({filePath: tc.file, allowEmpty: true})
  • m

    mysterious-sandwich-43667

    07/16/2022, 1:41 AM
    telling me to set allowEmpty to be true. Thought I did that. Not sure how my syntax is off.
  • m

    mysterious-sandwich-43667

    07/16/2022, 1:56 AM
    Looks like cypress-file-upload also doesn't get along with character entities in the file. Oh well.
  • l

    lively-guitar-99977

    07/16/2022, 12:18 PM
    I have the same problem. Did you find any solution?
  • l

    lively-guitar-99977

    07/16/2022, 1:17 PM
    I edited workflow of Github Actions to this:
    Copy code
    name: Cypress Tests
    
    on: [push]
    
    jobs:
      cypress-run:
        runs-on: ubuntu-latest
        steps:
          - name: Checkout
            uses: actions/checkout@v2
          - name: Install
            run: npm i --force
          - name: Build
            run: npm run build --force
          - name: Run React and Cypress
            run: npm run start & npm run cypress:run
  • m

    mysterious-sandwich-43667

    07/16/2022, 1:35 PM
    Looked at his code. Option-handling is too complicated for me to understand why it doesn't work, but changed allowEmpty to default to true in his code & now it works. Not a real solution of course
  • f

    famous-restaurant-30435

    07/16/2022, 6:24 PM
    @mysterious-sandwich-43667 - From your example above, you are selecting the upload button when you should be selecting the input. I think this is potentially your problem. Edit: Or you just have a poorly named selector.
  • m

    mysterious-sandwich-43667

    07/16/2022, 6:38 PM
    Oh boy. Anyway attachFile({filePath: fileName, allowEmpty: true} is not working and it doesn't look like he's updated that package in a long time. Other, normal uploads are just fine. Uploading and downloading files are holes in Cypress I hope they fix soon.
  • b

    billowy-hairdresser-82846

    07/17/2022, 7:33 AM
    #763105090679865354 needed
  • b

    billowy-hairdresser-82846

    07/17/2022, 7:33 AM
    My page object file is like below /// const LOGIN_PAGE_HEADER_TEXT = '.welcome-message > h1'; class LoginPage { get loginPageHeaderText() { return cy.get(LOGIN_PAGE_HEADER_TEXT, {timeout: 140000}); } } export default LoginPage; I want to use a custom command to check the Page header text and the text is dynamic So I tried to write a custom command like below Cypress.Commands.add('shouldContain', (element , text) => { cy.get(element).should('contain.text', text) }) but when I am using the custom command in my test file I am getting error. I am trying to use the custom command like below cy.shouldContain(loginPage.loginPageHeaderText, 'Welcome') The Error I am getting : Timed out retrying after 60000ms: expected { Object (0, length) } to contain text 'Forgot Password?', but the text was ''
  • a

    aloof-jordan-11481

    07/17/2022, 1:07 PM
    Hi, I am struggling to get my CI pipeline working with cypress. I am using Quasar and hava a PWA project. The Cypress tests all succeed if I start a local dev server with
    quasar dev -m pwa
    and let Cypress use it. Some of my tests always fail if I start the server with
    npx http-server
    . The failing tests validate whether certain API calls are made so nothing special really.
    Copy code
    let notoSansCount = 0;
        cy.intercept('**/NotoSans-Regular*.TTF', (req) => {
          notoSansCount += 1;
          req.continue();
        }).as('notoSansRegular');
    
        cy.visit('/');
    
        // this call is never made if I run it in http-server
        // this works reliably with quasar dev 
        cy.wait('@notoSansRegular');
    
        cy.dataCy('language-selection').then(() =>
          expect(notoSansCount).to.equal(1)
        );
  • w

    wonderful-match-15836

    07/17/2022, 6:10 PM
    Hi, from what I can tell this all looks fine, but you are not calling the
    loginPageHeaderText
    method to get the element.
    Copy code
    cy.shouldContain(loginPage.loginPageHeaderText, 'Welcome')
    should be:
    Copy code
    cy.shouldContain(loginPage.loginPageHeaderText(), 'Welcome')
  • r

    rhythmic-fall-53545

    07/17/2022, 7:08 PM
    How can i Configuring Cypress To Run On Different Environments at cypress 10 or later version?
  • a

    adorable-smartphone-87280

    07/17/2022, 7:28 PM
    set an environmental variable in your run script and then use conditional logic in your
    cypress.config.ts
    file.
  • r

    rhythmic-fall-53545

    07/17/2022, 7:32 PM
    Thank you so much awesome for your reply. Could you please suggest an article or blog so that I understand properly?
  • a

    adorable-smartphone-87280

    07/17/2022, 7:35 PM
    https://glebbahmutov.com/blog/cypress-v10-env/
  • a

    adorable-smartphone-87280

    07/17/2022, 7:37 PM
    In this example, a username and password value are set form the run script but you can also set something like
    --env testenv=1
    and then have logic like:
  • a

    adorable-smartphone-87280

    07/17/2022, 7:38 PM
    Copy code
    if (config.env.testenv) {
            return {
              config: property
            }
    } else return {
      default config
    }
    r
    • 2
    • 14
  • a

    adorable-smartphone-87280

    07/17/2022, 7:38 PM
    in your
    cypress.config.ts
  • a

    able-magazine-89300

    07/17/2022, 8:19 PM
    @wonderful-match-15836 Hi Mark its showing me the following error loginPage.loginPageHeaderText is not a function Because this error occurred during a before all hook we are skipping the remaining tests in the current suite: Test..
  • a

    able-magazine-89300

    07/17/2022, 8:20 PM
    Hi Mark its showing me the following error loginPage.loginPageHeaderText is not a function Because this error occurred during a before all hook we are skipping the remaining tests in the current suite: Test..
    w
    • 2
    • 2
  • w

    wonderful-match-15836

    07/17/2022, 8:42 PM
    Hi Mark its showing me the following
  • h

    handsome-dress-30825

    07/18/2022, 9:47 AM
    Hi everyone, I am having a strange issue with the
    cy.session
    command I don't explicitly logout the user between tests from the same spec file (I am still using Cypress version 9.7.0) and the login credentials that are passed to the session command are different than the previous ones (I see it in the command logs as well). However the command proceeds to the
    validate
    method to check if the session is valid, even though the user credentials were different. In the
    validate
    method I use
    expect().to.be.false
    type of validations to check if the token is still valid and since we do have a valid token it proceeds to use the previous user instead of logging in with the new one. Has anyone encountered such an issue and how did you handle it?
    • 1
    • 2
1...110111112...252Latest