Skip to content

Commit

Permalink
chore: fix net stubbing flake (#20297)
Browse files Browse the repository at this point in the history
Co-authored-by: Emily Rohrbough <[email protected]>
  • Loading branch information
ryanthemanuel and emilyrohrbough committed Feb 23, 2022
1 parent 8e365bc commit 05f9ad1
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/driver/cypress/integration/commands/net_stubbing_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,7 @@ describe('network stubbing', function () {
})
}).then(() => {
return $.get('/timeout').then((responseText) => {
expect(Date.now() - this.start).to.be.closeTo(250 + 100, 100)
expect(Date.now() - this.start).to.be.closeTo(delayMs + 100, 100)

done()
})
Expand All @@ -1664,7 +1664,7 @@ describe('network stubbing', function () {
const start = Date.now()

return $.get('/timeout').then((responseText) => {
expect(Date.now() - start).to.be.closeTo(delay, 50)
expect(Date.now() - start).to.be.closeTo(delay + 100, 100)
expect(responseText).to.eq('foo')
})
}
Expand Down Expand Up @@ -2583,16 +2583,18 @@ describe('network stubbing', function () {
})

it('can delay a proxy response using res.setDelay', function (done) {
const delay = 1000

cy.intercept('/timeout*', (req) => {
req.reply((res) => {
this.start = Date.now()

res.setDelay(1000).send('delay worked')
res.setDelay(delay).send('delay worked')
})
}).then(() => {
$.get('/timeout')
.done((responseText) => {
expect(Date.now() - this.start).to.be.closeTo(1100, 100)
expect(Date.now() - this.start).to.be.closeTo(delay + 100, 100)
expect(responseText).to.include('delay worked')

done()
Expand All @@ -2601,18 +2603,20 @@ describe('network stubbing', function () {
})

it('can \'delay\' a proxy response using Promise.delay', function (done) {
const delay = 1000

cy.intercept('/timeout*', (req) => {
req.reply((res) => {
this.start = Date.now()

return Promise.delay(1000)
return Promise.delay(delay)
.then(() => {
res.send('Promise.delay worked')
})
})
}).then(() => {
$.get('/timeout').then((responseText) => {
expect(Date.now() - this.start).to.be.closeTo(1000, 100)
expect(Date.now() - this.start).to.be.closeTo(delay + 100, 100)
expect(responseText).to.eq('Promise.delay worked')

done()
Expand Down

3 comments on commit 05f9ad1

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 05f9ad1 Feb 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.5.1/linux-x64/circle-develop-05f9ad163ec4ab13dc296b6ec184d28b5cea6670/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 05f9ad1 Feb 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.5.1/win32-x64/circle-develop-05f9ad163ec4ab13dc296b6ec184d28b5cea6670/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 05f9ad1 Feb 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.5.1/darwin-x64/circle-develop-05f9ad163ec4ab13dc296b6ec184d28b5cea6670/cypress.tgz

Please sign in to comment.