I have a call to my server (is a call that go to ibm watson) make somethings, and return me a 200 response if all is OK.
This call i bigger than 5000ms that cypress can wait. I need to wait until the server return the response, and then, i know that a popup will appear in my react app.
this is my call from my backend to watson:
const launchWatsonTest = (watsonData) => {
const data = {
withCredentials: true,
mode: 'cors',
headers: {
'x-access-token': watsonData.token,
},
params: {
topicId: watsonData.corpusNameId,
workspaceId: watsonData.corpusArea
}
};
return clienteAxios.post(`test-watson`, watsonData, data);
};
How can i wait before to continue with the test?
i have this test with cypress:
describe("E2E CognitiveTool", function() {
it("should crear respuesta simple sin problemas", function() {
cy.visit("http://localhost:3000");
cy.contains('[data-cy="topicName"]', 'CA2');
cy.get('[data-cy="accederResponsesCA2"]').click();
cy.get('[data-cy="crearResponse"]').should('exist')
.click();
cy.get('input[name="description"]')
.type('Simple Cypres Response');
cy.get('[name="typeResponse"]').first().check({force:true});
cy.get('[name="lateral_W"]').first().check({force:true});
cy.get('[name="rolViews"]').first().check({force:true});
cy.get('[name="workLoadLevel"]').first().check({force:true});
cy.get('[data-cy="continuar"]').click();
cy.get('input[id=0]')
.type('hola');
cy.get('input[id=1]')
.type('adios');
cy.get('input[id=2]')
.type('cypress');
cy.get('input[id=3]')
.type('jest');
cy.get('input[id=4]')
.type('testing');
cy.get('input[id=5]')
.type('automatico');
cy.get('[data-cy="testing"]').should('exist')
.click({force: true});
cy.waitUntil(()=>cy.intercept({method: 'POST', url:'**/test-watson'}).as('testData'), { // here is when i need to wait and then continue
timeout: 40000,
});
cy.wait('@testData');
cy.window()
.its('open')
.should('exist')
.get('[data-cy="continuar]').click();
});
});
I recieve this in command log in cypress console:
i did try with wait, with waitUntil, with getrequest() (that not works because i don't know how configure the headers error.....)
Some help for me. Thanks?