purple-afternoon-2408
07/15/2021, 3:37 PMuser
07/15/2021, 7:40 PMCache-Control
header with a max-age
and must-revalidate
), Cypress does not seem to be able to cy.wait
for the alias I setup:
* When running with cache disabled in chrome dev tools, my tests run fine
* With cache enabled however, the test fails because it does not record any of the calls made to this particular endpoint.
What's the correct way to handle this?ancient-wire-34126
07/15/2021, 8:10 PMancient-wire-34126
07/16/2021, 7:13 PMts
cy.intercept('OPTIONS', 'https://cognito-idp.us-east-1.amazonaws.com', { statusCode: 200 })
cy.intercept('POST', 'https://cognito-idp.us-east-1.amazonaws.com', {
statusCode: 200,
headers: {
'access-control-allow-origin': window.location.origin,
'Access-Control-Allow-Credentials': 'true',
}, body: {
// stuff
}
})
})
ancient-wire-34126
07/16/2021, 7:25 PMancient-wire-34126
07/16/2021, 7:45 PMstatusCode
manually for failed requests and only being able to load fixtures for 200's?ancient-wire-34126
07/16/2021, 7:47 PMwonderful-match-15836
07/16/2021, 7:59 PMCypress.Commands.add('interceptApi', (endpoint, fixturePath, statusCode = 200) => {
cy.intercept(INTERCEPT_API_URL + endpoint, {
statusCode,
fixture: `/${fixturePath}.json`,
}).as(fixturePath);
});
And we do stuff like cy.interceptApi('/yourEndpoint', 'lil-fixture-path/500-error', 500);
then make our assertions.ancient-wire-34126
07/16/2021, 8:00 PMancient-wire-34126
07/16/2021, 8:00 PMwonderful-match-15836
07/16/2021, 8:01 PMancient-wire-34126
07/16/2021, 8:01 PMancient-wire-34126
07/16/2021, 8:11 PMancient-wire-34126
07/16/2021, 8:15 PMts
it.only('Should login successfully', () => {
cy.intercept('POST', 'https://cognito-idp.us-east-1.amazonaws.com', { fixture: 'cognito/email-valid.json' }).as('baz')
cy.get('input#email').type(LOGIN_EMAIL_VALID)
cy.get('[data-login-email-submit]').click()
cy.wait('@baz')
cy.intercept('POST', 'https://cognito-idp.us-east-1.amazonaws.com', { fixture: 'cognito/auth-result.json' }).as('1')
cy.intercept('POST', 'https://cognito-identity.us-east-1.amazonaws.com', { fixture: 'cognito/id-1.json' }).as('2')
cy.intercept('POST', 'https://cognito-identity.us-east-1.amazonaws.com', { fixture: 'cognito/id-2.json' }).as('3')
cy.intercept('POST', 'https://cognito-idp.us-east-1.amazonaws.com', { fixture: 'cognito/auth-2.json' }).as('4')
cy.get('input#verification').type(LOGIN_CHALLENGE_VALID)
cy.get('[data-login-code-submit]').click()
cy.wait('@1')
cy.wait('@2')
cy.wait('@3')
cy.wait('@4')
cy.location('pathname', { timeout: 10000 }).should('include', 'profile')
})
It never waits for @1
ancient-wire-34126
07/16/2021, 8:16 PMancient-wire-34126
07/16/2021, 8:31 PMancient-wire-34126
07/16/2021, 8:31 PMancient-wire-34126
07/16/2021, 8:39 PMtimes
param also doesn't do anythingancient-wire-34126
07/16/2021, 8:46 PMancient-wire-34126
07/16/2021, 8:47 PMancient-wire-34126
07/16/2021, 9:07 PMpurple-afternoon-2408
07/19/2021, 10:43 AMpurple-afternoon-2408
07/19/2021, 1:19 PMalert-photographer-39416
07/19/2021, 7:34 PMhallowed-soccer-80135
07/20/2021, 6:17 AMhallowed-soccer-80135
07/20/2021, 6:26 AMcypress.run(config).then(results => {
console.log(results.runUrl)
})
fancy-airplane-60156
07/20/2021, 12:58 PMhallowed-soccer-80135
07/21/2021, 12:15 AMfancy-airplane-60156
07/21/2021, 3:08 AMpurple-afternoon-2408
07/21/2021, 5:09 PM