Hello i am a newbie with cypress and i feel blocked ,However i tried to slove the problem this is my test block, in my case after paying confirming an order i should be redirected to another page that , but i always get 401 Unauthorized status because i need the token. the problem is that i can't set the token in header of back-end api ?
it("Confirm order on the spot", () => {
cy.Authentification();
cy.server({
onAnyRequest: (route, proxy) => {
proxy.xhr.setRequestHeader('Authorization', cy.getLocalStorage('token'))
}
});
cy.route({
method: "POST",
url: "/api/*",
});
cy.get("#basket-button").click();
cy.get("#confirm-order").click();
cy.url().should("include", "/payment/method");
cy.get("#pay-on-spot").click();
cy.url().should("include", "/payment");
cy.get('input[placeholder="Entrez votre numéro de téléphone"]').type(
"0753949566"
);
cy.get('div[data-text-as-pseudo-element="Confirmer"]').parent().click();
});
Aucun commentaire:
Enregistrer un commentaire