赛普拉斯(Cypress

发布于 2025-02-10 05:24:49 字数 1577 浏览 1 评论 0原文

我有两个开始的测试块,但第二个测试总是失败。在JS代码中,我使用socket.io

[柏树检测到您从命令中返回承诺的

“已完成”和“取消 ”之间进行更改:

cy.wait()

您在承诺中调用的CY命令是:

cy.get()] image

我的代码

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');
  });
});

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');
  });
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文