Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise cy.wait and cy.get

Viewed 83

I have two blocks of tests that start similar but the second one always fails. In the JS code, I'm changing between "completed" and "canceled" with socket.io

[Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise

The command that returned the promise was:

cy.wait()

The cy command you invoked inside the promise was:

cy.get()] IMAGE

My code

describe('Logistic > History > Orders', () => {
  beforeEach(() => {
    cy.intercept('GET', '/v1/zones***').as('get-zones');
    cy.visit('/logistic/history');
  });
  
  it('Get the first canceled order and open modal', () => {
    cy.wait('@get-zones');
    cy.get('.css-6j8wv5-Input:first').click().type('san Jose{enter}');
    cy.get('.css-6j8wv5-Input').eq(1).click().type('canceled{enter}');
    cy.get('#date-init').type('2021-01-19');
    cy.get('.order-card:first').should('exist');

    cy.get('.order-card:first .view-order__text').click();
    cy.contains('Order #').should('exist');
  });

  it('Get the first completed order and open modal', () => {
    cy.wait('@get-zones');    
    cy.get('.css-6j8wv5-Input:first').click().type('san Jose{enter}');
    cy.get('.css-6j8wv5-Input').eq(1).click().type('completed{enter}');
    cy.get('#date-init').type('2021-01-19');
    cy.get('.order-card:first').should('exist');

    cy.get(
      'div.ordershistory-container > div.ordershistory-list > div.card_container:first > div:nth-child(3) > p'
    ).click();
    cy.contains('Order #').should('exist');
  });
});

0 Answers
Related