Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

214
Visualizações
CypressError: Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise

I am using cypress fixture and intercept to upload a file and also validate if the upload endpoint (post) was successful. here is the code:

describe('something', () => {
 
  let projectID;

  before(() => {
    projectID = localStorage.getItem('projectID');
   
    cy.intercept('POST', '/graphql', (req) => {
      cy.log(req.body);
      if (req.body.operationName === 'postRequest') {
        req.alias = 'postRequest';
      }
    });
  });

  it('should validate file upload', () => {
    const fileName = 'test_file_upload.xlsx';
    cy.get('.file-uploader').should('exist');
    cy.get('.upload-file-label').first().click({ force: true });
    cy.fixture(fileName, 'binary').then((fileContent) => {
      cy.get('input[type=file]')
        .upload(
          {
            fileContent,
            fileName,
            mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
            encoding: 'utf-8',
          },
          { subjectType: 'input' }
        )
        .wait('@postRequest')
        .then((interception) => {
          cy.log(interception.response.body);
        });
    });
  });
});

I am not exactly sure what is error refer to, but I am guessing it might be async issue.

thank you for your help

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The .wait() must be chained off a cy when you pass an alias.

// code looks good until here
cy.get('input[type=file]')
  .upload(
    {
      fileContent,
      fileName,
      mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
      encoding: 'utf-8',
    },
    { subjectType: 'input' }
  )
  cy.wait('@postRequest')
    .then((interception) => {
      cy.log(interception.response.body);
    });

When passed a time agrument (ie. 500) .wait() can be chained off a cy or any other command.

cy.get('.selector')
  .wait(1000)

cy.wait(500)
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda