user
05/29/2021, 1:42 AMuser
05/30/2021, 1:21 AMhelpful-lighter-43246
05/31/2021, 9:34 AMcy.intercept
along with cy.wait
Basically, we need to wait for a quite long list of initial calls to start up our app and this is what we are doing:
We have a custom command that intercepts the list of API calls
Cypress.Commands.add('interceptInitialLoad', (userKeyName = 'SUPER_USER') => { // possible values: SUPER_USER, FULL_VISIBILITY, CLIENT_CONFIGURATOR
cy.interceptWebSocket({ userKeyName });
initialLoadInterceptors.forEach((interceptor) => {
return cy.intercept(interceptor.match, interceptor[userKeyName].success).as(`initialLoad-${interceptor.key}`);
});
});
And a custom command to wait for all of those
Cypress.Commands.add('waitInitialLoad', (userKeyName = 'SUPER_USER') => { // possible values: SUPER_USER, FULL_VISIBILITY, CLIENT_CONFIGURATOR
const waitKeys = initialLoadInterceptors.map(interceptor => `@initialLoad-${interceptor.key}`);
return cy.wait(waitKeys.filter(key => {
if (userKeyName !== 'FULL_VISIBILITY') {
return key !== '@initialLoad-delegation' && key !== '@initialLoad-log' && key !== '@initialLoad-dataConnection';
}
return key !== '@initialLoad-delegation' && key !== '@initialLoad-log';
}));
});
But we randomly get such errors on CI
11:05:14 CypressError: Timed out retrying after 5000ms: `cy.wait()` timed out waiting `5000ms` for the 1st request to the route: `initialLoad-version`. No request ever occurred.
helpful-lighter-43246
05/31/2021, 9:34 AMhelpful-lighter-43246
05/31/2021, 9:34 AM"retries" : {
"runMode": 1,
"openMode": 0
}
helpful-lighter-43246
05/31/2021, 9:35 AMdescribe('Initial load', () => {
beforeEach(() => {
cy.viewport('macbook-15');
cy.interceptInitialLoad();
});
it('Loads app', () => {
cy.visit('/workspace');
cy.waitInitialLoad();
// https://github.com/NoriSte/cypress-wait-until
cy.waitUntil(() => cy.get('section.content[data-loaded="true"]')
.then($el => {
return Cypress.$($el).length === 1;
}));
});
});
helpful-lighter-43246
05/31/2021, 9:36 AMhelpful-lighter-43246
05/31/2021, 9:55 AMhelpful-lighter-43246
05/31/2021, 9:56 AMcypress run
helpful-lighter-43246
05/31/2021, 10:20 AMcy.wait
timing out is random on different routes, sometimes one sometimes on multiplehelpful-lighter-43246
05/31/2021, 3:54 PMstocky-dream-36427
05/31/2021, 5:01 PMstocky-dream-36427
05/31/2021, 5:02 PMstocky-dream-36427
05/31/2021, 5:03 PMstocky-dream-36427
05/31/2021, 5:04 PMhelpful-lighter-43246
05/31/2021, 6:01 PMbitter-fountain-36713
05/31/2021, 6:36 PMhelpful-lighter-43246
06/01/2021, 10:39 AMcy.intercept
are not doing their job there, but they alwasy work on local. I'm starting to think that that implmenetation in a forEach
might be the cause. Really all sounds like timing to me.miniature-portugal-41145
06/01/2021, 12:44 PMshould("not.be.visible") || should("be.hidden")
doesn't work as expected (the element hiding behind my drawer is still found by cypress and considered visible)miniature-portugal-41145
06/01/2021, 12:46 PMclick()
function on my hidden element fail. So Cypress know he can't click on it because it's hidden.miniature-portugal-41145
06/01/2021, 12:57 PMminiature-portugal-41145
06/01/2021, 12:57 PMacoustic-postman-68669
06/01/2021, 6:57 PMdescribe('Test TYPO3 Backend', () => {
it('Should show login', () => {
cy.wait(1000)
cy.visit('https://typo3.org/typo3/')
cy.wait(1000)
cy.get('#t3-username')
})
})
thankful-rocket-39348
06/02/2021, 10:33 AMthankful-rocket-39348
06/02/2021, 10:33 AMthankful-rocket-39348
06/02/2021, 10:37 AMhandsome-kilobyte-99728
06/03/2021, 6:07 PMbulky-sundown-74498
06/03/2021, 8:17 PMbulky-sundown-74498
06/03/2021, 8:18 PMhandsome-kilobyte-99728
06/03/2021, 8:18 PM