Skip to content

Commit

Permalink
test(cypress): Await promise in response to prevent timeout
Browse files Browse the repository at this point in the history
The idea is to intercept the request,
then test the loading state,
and after the tests continue the request.

Problem here: `cy.intercept` has a timeout on the request-handler
which uses the same timeout as DOM assertions (4s) we could increase it,
but this also will increase DOM assertion timeout.

So instead we do not await in the request handler, but in the response handler.
This should use the response timeout which is much higher (30s).

Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Sep 1, 2024
1 parent 8dd1696 commit 7e2bea6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cypress/e2e/files/files-renaming.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ describe('files: Rename nodes', { testIsolation: true }, () => {
cy.intercept(
'MOVE',
/\/remote.php\/dav\/files\//,
async () => { await promise },
(request) => {
// we need to wait in the onResponse handler as the intercept handler times out otherwise
request.on('response', async () => { await promise })
},
).as('moveFile')

// Start the renaming
Expand Down

0 comments on commit 7e2bea6

Please sign in to comment.