-
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.
- Loading branch information
Showing
4 changed files
with
92 additions
and
0 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
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,36 @@ | ||
/// <reference path="../../src/index.d.ts" /> | ||
// @ts-check | ||
|
||
import '../..' | ||
|
||
describe('Waiting for POST requests', () => { | ||
it('ignores the GET requests', () => { | ||
// listen to all POST calls | ||
cy.waitForNetworkIdlePrepare({ | ||
method: 'POST', | ||
pattern: '*', | ||
alias: 'postCalls', | ||
}) | ||
|
||
cy.visit('/get-vs-post') | ||
cy.waitForNetworkIdle('@postCalls', 2000).then(({ waited, callCount }) => { | ||
expect(callCount, 'call count').to.equal(1) | ||
expect(waited, 'waited period').to.be.within(3500, 4500) | ||
}) | ||
}) | ||
|
||
it('waits for specific POST route only', () => { | ||
// listen to "POST /add-user" calls | ||
cy.waitForNetworkIdlePrepare({ | ||
method: 'POST', | ||
pattern: '/add-user', | ||
alias: 'addUser', | ||
}) | ||
|
||
cy.visit('/get-vs-post') | ||
cy.waitForNetworkIdle('@addUser', 2000).then(({ waited, callCount }) => { | ||
expect(callCount, 'call count').to.equal(1) | ||
expect(waited, 'waited period').to.be.within(3500, 4500) | ||
}) | ||
}) | ||
}) |
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,22 @@ | ||
<html> | ||
<head> | ||
<title>Get vs post</title> | ||
</head> | ||
<body> | ||
<h1>cypress-network-idle page with lots of GET requests</h1> | ||
<p>but only a few POST requests</p> | ||
<script> | ||
// make constant GET requests | ||
setInterval(() => { | ||
fetch('/user') | ||
}, 1000) | ||
|
||
// make a single POST request | ||
setTimeout(() => { | ||
fetch('/add-user', { | ||
method: 'POST', | ||
}) | ||
}, 1500) | ||
</script> | ||
</body> | ||
</html> |
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