-
Notifications
You must be signed in to change notification settings - Fork 13
/
get-vs-post.js
47 lines (41 loc) · 1.33 KB
/
get-vs-post.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/// <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)
})
})
it('waits for specific POST route only using single command', () => {
cy.visit('/get-vs-post')
// listen to "POST /add-user" calls
cy.waitForNetworkIdle('POST', '/add-user', 2000).then(
({ waited, callCount }) => {
expect(callCount, 'call count').to.equal(1)
expect(waited, 'waited period').to.be.within(3500, 4500)
},
)
})
})