如何在赛普拉斯的Chrome中访问网络通话?

时间:2019-11-29 12:41:18

标签: javascript google-chrome visual-studio-code cypress

此路径不起作用/////

我想在这里访问

enter image description here

describe('Second GA Tracking', () => {
  it('should be called', () => {
    cy.server();
    // cy.fixture('cypress/fixture/fixture.json').as('@getSecondGA');
    cy.visit(chps.url);
    cy.wait('UA-5883199-36').then((img) => {
      assert.isNotNull(img.response.body.data, 'Second GA Tracking call has data');
    });
  });
});

1 个答案:

答案 0 :(得分:0)

您错过了cy.route()通话。试试这个:

describe('Second GA Tracking', () => {
  it('should be called', () => {
    cy.server();
    cy.route('**UA-5883199-36**').as('getRequest');
    cy.visit(chps.url);
    cy.wait('@getRequest').then(request => {
      assert.isNotNull(request.response.body.data, 'Second GA Tracking call has data');
    });
  });
});

https://docs.cypress.io/api/commands/route.html