Skip to content

Commit 05f9ad1

Browse files
chore: fix net stubbing flake (#20297)
Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
1 parent 8e365bc commit 05f9ad1

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

packages/driver/cypress/integration/commands/net_stubbing_spec.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,7 @@ describe('network stubbing', function () {
16491649
})
16501650
}).then(() => {
16511651
return $.get('/timeout').then((responseText) => {
1652-
expect(Date.now() - this.start).to.be.closeTo(250 + 100, 100)
1652+
expect(Date.now() - this.start).to.be.closeTo(delayMs + 100, 100)
16531653

16541654
done()
16551655
})
@@ -1664,7 +1664,7 @@ describe('network stubbing', function () {
16641664
const start = Date.now()
16651665

16661666
return $.get('/timeout').then((responseText) => {
1667-
expect(Date.now() - start).to.be.closeTo(delay, 50)
1667+
expect(Date.now() - start).to.be.closeTo(delay + 100, 100)
16681668
expect(responseText).to.eq('foo')
16691669
})
16701670
}
@@ -2583,16 +2583,18 @@ describe('network stubbing', function () {
25832583
})
25842584

25852585
it('can delay a proxy response using res.setDelay', function (done) {
2586+
const delay = 1000
2587+
25862588
cy.intercept('/timeout*', (req) => {
25872589
req.reply((res) => {
25882590
this.start = Date.now()
25892591

2590-
res.setDelay(1000).send('delay worked')
2592+
res.setDelay(delay).send('delay worked')
25912593
})
25922594
}).then(() => {
25932595
$.get('/timeout')
25942596
.done((responseText) => {
2595-
expect(Date.now() - this.start).to.be.closeTo(1100, 100)
2597+
expect(Date.now() - this.start).to.be.closeTo(delay + 100, 100)
25962598
expect(responseText).to.include('delay worked')
25972599

25982600
done()
@@ -2601,18 +2603,20 @@ describe('network stubbing', function () {
26012603
})
26022604

26032605
it('can \'delay\' a proxy response using Promise.delay', function (done) {
2606+
const delay = 1000
2607+
26042608
cy.intercept('/timeout*', (req) => {
26052609
req.reply((res) => {
26062610
this.start = Date.now()
26072611

2608-
return Promise.delay(1000)
2612+
return Promise.delay(delay)
26092613
.then(() => {
26102614
res.send('Promise.delay worked')
26112615
})
26122616
})
26132617
}).then(() => {
26142618
$.get('/timeout').then((responseText) => {
2615-
expect(Date.now() - this.start).to.be.closeTo(1000, 100)
2619+
expect(Date.now() - this.start).to.be.closeTo(delay + 100, 100)
26162620
expect(responseText).to.eq('Promise.delay worked')
26172621

26182622
done()

0 commit comments

Comments
 (0)