nutritious-restaurant-91514
05/14/2021, 7:31 AMpurple-afternoon-2408
05/14/2021, 11:51 AMcy.intercept
which would intercept those requests made by the web app, and also it can be used to stub the responses, is there a way that I can also intercept cy.request
made by cypress
?user
05/14/2021, 3:42 PMimportant-hydrogen-31560
05/14/2021, 3:48 PMimportant-hydrogen-31560
05/14/2021, 3:49 PMimportant-hydrogen-31560
05/14/2021, 3:50 PMstocky-dream-36427
05/14/2021, 4:01 PMstocky-dream-36427
05/14/2021, 4:01 PMnutritious-restaurant-91514
05/14/2021, 6:57 PMfuture-journalist-95278
05/18/2021, 6:57 AMfuture-journalist-95278
05/18/2021, 6:58 AMincalculable-rocket-67453
05/18/2021, 9:10 AMmammoth-arm-34681
05/19/2021, 7:11 PMfuture-journalist-95278
05/19/2021, 9:55 PMmammoth-arm-34681
05/20/2021, 7:01 AMcy.request({
method: 'GET',
url: `https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Messages.json?PageSize=${MESSAGES_LIMIT}&To=${phoneNumber}`,
auth: {
username: accountSid,
password: authToken,
}
})
and for each of them delete:
cy.request({
method: 'DELETE',
url: `https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Messages/${message.sid}.json`,
auth: {
username: accountSid,
password: authToken,
}
});
and then wait for a new incoming messageclean-nail-36816
05/20/2021, 5:26 PMbulky-sundown-74498
05/20/2021, 7:36 PMbulky-sundown-74498
05/20/2021, 7:36 PMalert-photographer-39416
05/20/2021, 7:36 PMbulky-sundown-74498
05/20/2021, 7:36 PMbulky-sundown-74498
05/20/2021, 7:36 PMalert-photographer-39416
05/20/2021, 7:38 PMalert-photographer-39416
05/20/2021, 7:38 PMalert-photographer-39416
05/20/2021, 7:39 PMalert-photographer-39416
05/20/2021, 7:40 PMNEXTAUTH_URL environment variable not set
rough-fish-62491
05/20/2021, 8:18 PMrough-fish-62491
05/20/2021, 8:18 PMstocky-dream-36427
05/20/2021, 8:41 PMfuture-journalist-95278
05/20/2021, 9:58 PMjs
Cypress.Commands.add('login', () => {
const data = JSON.stringify({
username: Cypress.env('TEST_USERNAME'),
password: Cypress.env('TEST_USER_PASSWORD'),
})
cy.window().then((window) => {
window.nuxtApp.$auth.loginWith('login', data)
})
})
What I don't understand is this is giving me a Xhr
request with canceled: true
. I read that canceled: true
occurs because I am attempting a URL change after calling my login command like: js
cy.login()
cy.visit('http://localhost:3000/settings/info')
Should I be waiting for the login command to finish? I tried adding an alias like: js
cy.login().as('login')
cy.wait('@login')
but Cypress didn't seem to like that...narrow-optician-44716
05/21/2021, 4:09 PM// ...
watch: {
sessionExpiration: {
handler: 'startSessionTimer',
immediate: true
},
// ...
},
methods: {
// ...
startSessionTimer (expiration) {
this.clearTimer();
if (!expiration) return;
const timeout = expiration.getTime() - Date.now();
console.log({ expiration, now: new Date(), timeout });
this.timeoutId = setTimeout(() => {
console.log({ timeoutExecuted: new Date() });
// this.alertAndSignOut();
}, timeout);
},
// ...
Things work OK when I run the app, but during e2e tests, the setTimeout executes immediately, even with very lengthy expiration dates.