mirror of
https://github.com/cypress-io/cypress.git
synced 2026-03-03 05:19:45 -06:00
Merge remote-tracking branch 'origin/develop' into 10.0-release
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const _ = require('lodash')
|
||||
const arch = require('arch')
|
||||
const os = require('os')
|
||||
const url = require('url')
|
||||
const path = require('path')
|
||||
@@ -105,7 +106,7 @@ const getBinaryUrlFromPrereleaseNpmUrl = (npmUrl) => {
|
||||
|
||||
const { version, artifactSlug } = matches.groups
|
||||
|
||||
parsed.pathname = `/beta/binary/${version}/${os.platform()}-${os.arch()}/${artifactSlug}/cypress.zip`
|
||||
parsed.pathname = `/beta/binary/${version}/${os.platform()}-${arch()}/${artifactSlug}/cypress.zip`
|
||||
|
||||
return parsed.format()
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@
|
||||
"p-defer": "^3.0.0",
|
||||
"parse-github-repo-url": "1.4.1",
|
||||
"patch-package": "6.4.7",
|
||||
"plist": "3.0.1",
|
||||
"plist": "3.0.4",
|
||||
"pluralize": "8.0.0",
|
||||
"postinstall-postinstall": "2.0.0",
|
||||
"prefixed-list": "1.0.1",
|
||||
|
||||
@@ -1650,7 +1650,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()
|
||||
})
|
||||
@@ -1665,7 +1665,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')
|
||||
})
|
||||
}
|
||||
@@ -2584,16 +2584,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()
|
||||
@@ -2602,18 +2604,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()
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"execa": "4.0.0",
|
||||
"fs-extra": "9.1.0",
|
||||
"lodash": "^4.17.21",
|
||||
"plist": "3.0.1",
|
||||
"plist": "3.0.4",
|
||||
"semver": "7.3.5",
|
||||
"win-version-info": "5.0.1"
|
||||
},
|
||||
|
||||
@@ -251,10 +251,6 @@ export function getBodyEncoding (req: CyHttpMessages.IncomingRequest): BodyEncod
|
||||
if (contentType.includes('charset=utf-8') || contentType.includes('charset="utf-8"')) {
|
||||
return 'utf8'
|
||||
}
|
||||
|
||||
if (contentType.includes('multipart/form-data')) {
|
||||
return 'binary'
|
||||
}
|
||||
}
|
||||
|
||||
// with fallback to inspecting the buffer using
|
||||
|
||||
@@ -69,19 +69,5 @@ describe('net-stubbing util', () => {
|
||||
|
||||
expect(getBodyEncoding(req), 'image').to.equal('binary')
|
||||
})
|
||||
|
||||
it('returns binary for form-data bodies', () => {
|
||||
const formDataRequest = {
|
||||
body: Buffer.from('hello world'),
|
||||
headers: {
|
||||
'content-type': 'multipart/form-data',
|
||||
},
|
||||
method: 'POST',
|
||||
url: 'somewhere',
|
||||
httpVersion: '1.1',
|
||||
}
|
||||
|
||||
expect(getBodyEncoding(formDataRequest)).to.equal('binary')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -11,7 +11,7 @@ export function byPortAndAddress (port: number, address: net.Address) {
|
||||
// https://nodejs.org/api/net.html#net_net_connect_port_host_connectlistener
|
||||
return new Bluebird<net.Address>((resolve, reject) => {
|
||||
const onConnect = () => {
|
||||
client.end()
|
||||
client.destroy()
|
||||
resolve(address)
|
||||
}
|
||||
|
||||
|
||||
27
packages/network/test/unit/connect_spec.ts
Normal file
27
packages/network/test/unit/connect_spec.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { connect } from '../..'
|
||||
import { expect } from 'chai'
|
||||
import sinon from 'sinon'
|
||||
import net from 'net'
|
||||
|
||||
describe('lib/connect', () => {
|
||||
context('.byPortAndAddress', () => {
|
||||
it('destroy connection immediately onConnect', () => {
|
||||
const socket = new net.Socket()
|
||||
const destroy = sinon.spy(socket, 'destroy')
|
||||
|
||||
sinon.stub(net, 'connect').callsFake((port, address, onConnect) => {
|
||||
process.nextTick(() => {
|
||||
onConnect()
|
||||
})
|
||||
|
||||
return socket
|
||||
})
|
||||
|
||||
return connect.byPortAndAddress(1234, { address: '127.0.0.1' })
|
||||
.then((address) => {
|
||||
expect(address).to.deep.eq({ address: '127.0.0.1' })
|
||||
expect(destroy).to.be.called
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
28
yarn.lock
28
yarn.lock
@@ -13756,7 +13756,7 @@ base64-arraybuffer@0.1.4:
|
||||
resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.4.tgz#9818c79e059b1355f97e0428a017c838e90ba812"
|
||||
integrity sha1-mBjHngWbE1X5fgQooBfIOOkLqBI=
|
||||
|
||||
base64-js@^1.0.2, base64-js@^1.2.3, base64-js@^1.3.1:
|
||||
base64-js@^1.0.2, base64-js@^1.3.1, base64-js@^1.5.1:
|
||||
version "1.5.1"
|
||||
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
|
||||
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==
|
||||
@@ -32817,14 +32817,13 @@ please-upgrade-node@^3.2.0:
|
||||
dependencies:
|
||||
semver-compare "^1.0.0"
|
||||
|
||||
plist@3.0.1, plist@^3.0.0, plist@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.1.tgz#a9b931d17c304e8912ef0ba3bdd6182baf2e1f8c"
|
||||
integrity sha512-GpgvHHocGRyQm74b6FWEZZVRroHKE1I0/BTjAmySaohK+cUn+hZpbqXkc3KWgW3gQYkqcQej35FohcT0FRlkRQ==
|
||||
plist@3.0.4, plist@^3.0.0, plist@^3.0.1:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.4.tgz#a62df837e3aed2bb3b735899d510c4f186019cbe"
|
||||
integrity sha512-ksrr8y9+nXOxQB2osVNqrgvX/XQPOXaU4BQMKjYq8PvaY1U18mo+fKgBSwzK+luSyinOuPae956lSVcBwxlAMg==
|
||||
dependencies:
|
||||
base64-js "^1.2.3"
|
||||
base64-js "^1.5.1"
|
||||
xmlbuilder "^9.0.7"
|
||||
xmldom "0.1.x"
|
||||
|
||||
plugin-error@^0.1.2:
|
||||
version "0.1.2"
|
||||
@@ -41803,7 +41802,7 @@ url-parse-lax@^3.0.0:
|
||||
dependencies:
|
||||
prepend-http "^2.0.0"
|
||||
|
||||
url-parse@1.5.6:
|
||||
url-parse@1.5.6, url-parse@^1.4.3, url-parse@^1.4.7:
|
||||
version "1.5.6"
|
||||
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.6.tgz#b2a41d5a233645f3c31204cc8be60e76a15230a2"
|
||||
integrity sha512-xj3QdUJ1DttD1LeSfvJlU1eiF1RvBSBfUu8GplFGdUzSO28y5yUtEl7wb//PI4Af6qh0o/K8545vUmucRrfWsw==
|
||||
@@ -41811,14 +41810,6 @@ url-parse@1.5.6:
|
||||
querystringify "^2.1.1"
|
||||
requires-port "^1.0.0"
|
||||
|
||||
url-parse@^1.4.3, url-parse@^1.4.7:
|
||||
version "1.5.2"
|
||||
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.2.tgz#a4eff6fd5ff9fe6ab98ac1f79641819d13247cda"
|
||||
integrity sha512-6bTUPERy1muxxYClbzoRo5qtQuyoGEbzbQvi0SW4/8U8UyVkAQhWFBlnigqJkRm4su4x1zDQfNbEzWkt+vchcg==
|
||||
dependencies:
|
||||
querystringify "^2.1.1"
|
||||
requires-port "^1.0.0"
|
||||
|
||||
url-template@^2.0.8:
|
||||
version "2.0.8"
|
||||
resolved "https://registry.yarnpkg.com/url-template/-/url-template-2.0.8.tgz#fc565a3cccbff7730c775f5641f9555791439f21"
|
||||
@@ -44263,11 +44254,6 @@ xmlchars@^2.1.1:
|
||||
resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"
|
||||
integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==
|
||||
|
||||
xmldom@0.1.x:
|
||||
version "0.1.31"
|
||||
resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.1.31.tgz#b76c9a1bd9f0a9737e5a72dc37231cf38375e2ff"
|
||||
integrity sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ==
|
||||
|
||||
xmlhttprequest-ssl@~1.5.4:
|
||||
version "1.5.5"
|
||||
resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz#c2876b06168aadc40e57d97e81191ac8f4398b3e"
|
||||
|
||||
Reference in New Issue
Block a user