Skip to content

Commit

Permalink
chore(contributing): fix network_error_handling_spec for external con…
Browse files Browse the repository at this point in the history
…tributors
  • Loading branch information
flotwig committed Feb 7, 2022
1 parent 4a976d7 commit 04a151e
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions system-tests/test/network_error_handling_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const chrome = require('@packages/server/lib/browsers/chrome')
const systemTests = require('../lib/system-tests').default
const random = require('@packages/server/lib/util/random')
const Fixtures = require('../lib/fixtures')
let mitmProxy = require('http-mitm-proxy')
const MitmProxy = require('http-mitm-proxy')

const PORT = 13370
const PROXY_PORT = 13371
Expand Down Expand Up @@ -348,19 +348,19 @@ describe('e2e network error handling', function () {
})

context('Cypress', () => {
let debugProxy

beforeEach(() => {
delete process.env.HTTP_PROXY
delete process.env.HTTPS_PROXY

return delete process.env.NO_PROXY
delete process.env.NO_PROXY
})

afterEach(function () {
if (this.debugProxy) {
return this.debugProxy.stop()
.then(() => {
this.debugProxy = null
})
afterEach(async function () {
if (debugProxy) {
await debugProxy.stop()
debugProxy = null
}
})

Expand Down Expand Up @@ -415,11 +415,11 @@ describe('e2e network error handling', function () {
return true
})

this.debugProxy = new DebugProxy({
debugProxy = new DebugProxy({
onConnect,
})

return this.debugProxy
return debugProxy
.start(PROXY_PORT)
.then(() => {
process.env.HTTP_PROXY = `http://localhost:${PROXY_PORT}`
Expand Down Expand Up @@ -452,6 +452,15 @@ describe('e2e network error handling', function () {

// https://github.com/cypress-io/cypress/issues/4298
context('does not delay a 304 Not Modified', () => {
let mitmProxy

beforeEach(() => {
if (mitmProxy) {
mitmProxy.close()
mitmProxy = null
}
})

it('in normal network conditions', function () {
return systemTests.exec(this, {
spec: 'network_error_304_handling_spec.js',
Expand All @@ -465,9 +474,9 @@ describe('e2e network error handling', function () {
})

it('behind a proxy', function () {
this.debugProxy = new DebugProxy()
debugProxy = new DebugProxy()

return this.debugProxy
return debugProxy
.start(PROXY_PORT)
.then(() => {
process.env.HTTP_PROXY = `http://localhost:${PROXY_PORT}`
Expand All @@ -486,7 +495,7 @@ describe('e2e network error handling', function () {
})

it('behind a proxy with transfer-encoding: chunked', function () {
mitmProxy = mitmProxy()
mitmProxy = MitmProxy()

mitmProxy.onRequest((ctx, callback) => {
return callback()
Expand Down

0 comments on commit 04a151e

Please sign in to comment.