I'm testing React Application that pre rendered with Next.js. My application have two pass rendering: loading screen and actual app screen. So I wrote cypress test like this:
// using @testing-library/cypress
it('Some of my tests', () => {
cy.visit('http://localhost:4000/annotation/edit');
// bypass next.js router alert outside of my app
cy.get('div#__next').findByRole('alert', { name: /loading/i });
cy.findByRole('form', { name: /sign in form/i }).within(() => {
cy.findByRole('textbox', { name: /account name/i }).type('...');
cy.findByRole('textbox', { name: /email/i }).type('...');
cy.findByLabelText(/password/i).type('...');
cy.findByRole('button', { name: /sign in/i }).click();
});
cy.findByRole('progressbar');
});
But it sometimes success, sometimes fail by skipping the first screen. I checked with cypress video and browser runner, there was loading screen and transition to actual app. But Cypress couldn't capture it. The alert in loading screen has accesible name /loading
is not conditional, always same. I think Cypress is unstable at rendering.
Is there any way to make a throttle in some steps or capture current DOM?