-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testing inflight and delayed network requests (#67)
* investigate the inflight timings * adding more testing
- Loading branch information
Showing
4 changed files
with
48 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/// <reference path="../../src/index.d.ts" /> | ||
// @ts-check | ||
|
||
import '../../src' | ||
|
||
it( | ||
'waits for the request that starts later', | ||
{ viewportHeight: 300, viewportWidth: 500 }, | ||
() => { | ||
cy.visit('/after') | ||
cy.get('#fetch-delay').clear().type(String(1000)) | ||
cy.get('#server-delay').clear().type(String(1000)) | ||
|
||
cy.waitForNetworkIdlePrepare({ | ||
method: 'GET', | ||
pattern: '/after/*', | ||
alias: 'after', | ||
}) | ||
cy.get('#fetch').click() | ||
// by the time we start waiting, the network request is already out | ||
cy.waitForNetworkIdle('@after', 1100).then(({ waited, callCount }) => { | ||
expect(callCount, 'callCount').to.equal(1) | ||
// call starts after 1000ms | ||
// call lasts 1000ms | ||
// plus idle wait for 1100ms | ||
// together between 3100 and 3200ms | ||
expect(waited, 'waited').to.be.within(3100, 3500) | ||
}) | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters