gentle-accountant-4760
07/04/2022, 1:31 PMts
And('when we are make a requests to the barrthrill api', () => {
const url = `${constants.baseUrl.api}/barrythrill/user/123455`.trim();
const pathToSign = Helper.getPathToSign(url );
const timeStamp = Helper.formatDateISOBasic(new Date());
const headers = [
{ name: 'provider', value: 'thrill' },
{ name: 'key', value: '12345' },
{ name: 'environment', value: 'DevTest' },
{ name: 'timestamp', value: timeStamp },
];
const corndog = {};
Object.entries(headers).forEach(([, header]) => { corndog[header.name] = header.value; });
cy.task('ThrillSignature', { pathToSign, headers }).then((signature) => {
cy.request({
url: url ,
method: 'GET',
headers: {
...corndog,
'signature': signature,
},
failOnStatusCode: false,
log: true,
})
.then((response) => {
cy.log('resp', JSON.stringify(response));
});
});
});
Do you have any other suggestions on how I could perhaps improve?fresh-doctor-14925
07/04/2022, 1:39 PMcy.task()
? That seems a little redundant to megentle-accountant-4760
07/04/2022, 1:40 PMgentle-accountant-4760
07/04/2022, 1:40 PMgentle-accountant-4760
07/04/2022, 1:40 PMts
async ThrillSignature({ pathToSign, headers }) {
const signer = new MessageSigner();
const signature = signer.getSignature('barrythrill', pathToSign, headers, []);
return signature;
},
gentle-accountant-4760
07/04/2022, 1:41 PMgentle-accountant-4760
07/04/2022, 1:41 PMfresh-doctor-14925
07/04/2022, 1:41 PMfailOnStatusCode: false
. You're presumably going to be asserting on the response in some other way?fresh-doctor-14925
07/04/2022, 1:41 PMgentle-accountant-4760
07/04/2022, 1:42 PMgentle-accountant-4760
07/04/2022, 1:42 PMfresh-doctor-14925
07/04/2022, 1:42 PMcypress-wait-until
or cypress-recurse
plugins so that you can retry until you get a success responsegentle-accountant-4760
07/04/2022, 1:43 PMgentle-accountant-4760
07/04/2022, 1:43 PMgentle-accountant-4760
07/04/2022, 1:43 PMgentle-accountant-4760
07/04/2022, 1:43 PMgentle-accountant-4760
07/04/2022, 1:43 PMfresh-doctor-14925
07/04/2022, 1:46 PMfresh-doctor-14925
07/04/2022, 1:47 PMurl: url,
to just url,
in your call to cy.request()
but that's nitpickinggentle-accountant-4760
07/04/2022, 1:48 PMgentle-accountant-4760
07/04/2022, 1:48 PMgentle-accountant-4760
07/04/2022, 1:48 PMgentle-accountant-4760
07/04/2022, 1:48 PMgentle-accountant-4760
07/04/2022, 1:48 PMfresh-doctor-14925
07/04/2022, 1:50 PMgentle-accountant-4760
07/04/2022, 1:50 PM