mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-04 14:00:22 -05:00
Merge branch develop into 9.0-release
This commit is contained in:
@@ -9,6 +9,7 @@ const request = require('@cypress/request')
|
||||
const Promise = require('bluebird')
|
||||
const requestProgress = require('request-progress')
|
||||
const { stripIndent } = require('common-tags')
|
||||
const getProxyForUrl = require('proxy-from-env').getProxyForUrl
|
||||
|
||||
const { throwFormErrorText, errors } = require('../errors')
|
||||
const fs = require('../fs')
|
||||
@@ -16,12 +17,9 @@ const util = require('../util')
|
||||
|
||||
const defaultBaseUrl = 'https://download.cypress.io/'
|
||||
|
||||
const getProxyUrl = () => {
|
||||
return process.env.HTTPS_PROXY ||
|
||||
process.env.https_proxy ||
|
||||
const getProxyForUrlWithNpmConfig = (url) => {
|
||||
return getProxyForUrl(url) ||
|
||||
process.env.npm_config_https_proxy ||
|
||||
process.env.HTTP_PROXY ||
|
||||
process.env.http_proxy ||
|
||||
process.env.npm_config_proxy ||
|
||||
null
|
||||
}
|
||||
@@ -205,7 +203,7 @@ const verifyDownloadedFile = (filename, expectedSize, expectedChecksum) => {
|
||||
// {filename: ..., downloaded: true}
|
||||
const downloadFromUrl = ({ url, downloadDestination, progress, ca }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const proxy = getProxyUrl()
|
||||
const proxy = getProxyForUrlWithNpmConfig(url)
|
||||
|
||||
debug('Downloading package', {
|
||||
url,
|
||||
@@ -357,6 +355,6 @@ const start = (opts) => {
|
||||
module.exports = {
|
||||
start,
|
||||
getUrl,
|
||||
getProxyUrl,
|
||||
getProxyForUrlWithNpmConfig,
|
||||
getCA,
|
||||
}
|
||||
|
||||
+2
-1
@@ -20,7 +20,7 @@
|
||||
"unit": "cross-env BLUEBIRD_DEBUG=1 NODE_ENV=test mocha --reporter mocha-multi-reporters --reporter-options configFile=../mocha-reporter-config.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cypress/request": "^2.88.5",
|
||||
"@cypress/request": "^2.88.6",
|
||||
"@cypress/xvfb": "^1.2.4",
|
||||
"@types/node": "^14.14.31",
|
||||
"@types/sinonjs__fake-timers": "^6.0.2",
|
||||
@@ -54,6 +54,7 @@
|
||||
"minimist": "^1.2.5",
|
||||
"ospath": "^1.2.2",
|
||||
"pretty-bytes": "^5.6.0",
|
||||
"proxy-from-env": "1.0.0",
|
||||
"ramda": "~0.27.1",
|
||||
"request-progress": "^3.0.0",
|
||||
"supports-color": "^8.1.1",
|
||||
|
||||
@@ -313,28 +313,60 @@ describe('lib/tasks/download', function () {
|
||||
})
|
||||
|
||||
context('with proxy env vars', () => {
|
||||
const testUriHttp = 'http://anything.com'
|
||||
const testUriHttps = 'https://anything.com'
|
||||
|
||||
beforeEach(function () {
|
||||
this.env = _.clone(process.env)
|
||||
// add a default no_proxy which does not match the testUri
|
||||
process.env.NO_PROXY = 'localhost,.org'
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
process.env = this.env
|
||||
})
|
||||
|
||||
it('prefers https_proxy over http_proxy', () => {
|
||||
process.env.HTTP_PROXY = 'foo'
|
||||
expect(download.getProxyUrl()).to.eq('foo')
|
||||
process.env.https_proxy = 'bar'
|
||||
expect(download.getProxyUrl()).to.eq('bar')
|
||||
it('uses http_proxy on http request', () => {
|
||||
process.env.http_proxy = 'http://foo'
|
||||
expect(download.getProxyForUrlWithNpmConfig(testUriHttp)).to.eq('http://foo')
|
||||
})
|
||||
|
||||
it('ignores http_proxy on https request', () => {
|
||||
process.env.http_proxy = 'http://foo'
|
||||
expect(download.getProxyForUrlWithNpmConfig(testUriHttps)).to.eq(null)
|
||||
process.env.https_proxy = 'https://bar'
|
||||
expect(download.getProxyForUrlWithNpmConfig(testUriHttps)).to.eq('https://bar')
|
||||
})
|
||||
|
||||
it('falls back to npm_config_proxy', () => {
|
||||
process.env.npm_config_proxy = 'foo'
|
||||
expect(download.getProxyUrl()).to.eq('foo')
|
||||
process.env.npm_config_https_proxy = 'bar'
|
||||
expect(download.getProxyUrl()).to.eq('bar')
|
||||
process.env.https_proxy = 'baz'
|
||||
expect(download.getProxyUrl()).to.eq('baz')
|
||||
process.env.npm_config_proxy = 'http://foo'
|
||||
expect(download.getProxyForUrlWithNpmConfig(testUriHttps)).to.eq('http://foo')
|
||||
process.env.npm_config_https_proxy = 'https://bar'
|
||||
expect(download.getProxyForUrlWithNpmConfig(testUriHttps)).to.eq('https://bar')
|
||||
process.env.https_proxy = 'https://baz'
|
||||
expect(download.getProxyForUrlWithNpmConfig(testUriHttps)).to.eq('https://baz')
|
||||
})
|
||||
|
||||
it('respects no_proxy on http and https requests', () => {
|
||||
process.env.NO_PROXY = 'localhost,.com'
|
||||
|
||||
process.env.http_proxy = 'http://foo'
|
||||
process.env.https_proxy = 'https://bar'
|
||||
|
||||
expect(download.getProxyForUrlWithNpmConfig(testUriHttp)).to.eq(null)
|
||||
expect(download.getProxyForUrlWithNpmConfig(testUriHttps)).to.eq(null)
|
||||
})
|
||||
|
||||
it('ignores no_proxy for npm proxy configs, prefers https over http', () => {
|
||||
process.env.NO_PROXY = 'localhost,.com'
|
||||
|
||||
process.env.npm_config_proxy = 'http://foo'
|
||||
expect(download.getProxyForUrlWithNpmConfig(testUriHttp)).to.eq('http://foo')
|
||||
expect(download.getProxyForUrlWithNpmConfig(testUriHttps)).to.eq('http://foo')
|
||||
|
||||
process.env.npm_config_https_proxy = 'https://bar'
|
||||
expect(download.getProxyForUrlWithNpmConfig(testUriHttp)).to.eq('https://bar')
|
||||
expect(download.getProxyForUrlWithNpmConfig(testUriHttps)).to.eq('https://bar')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Vendored
+79
-12
@@ -22,6 +22,19 @@ declare namespace Cypress {
|
||||
password: string
|
||||
}
|
||||
|
||||
interface RemoteState {
|
||||
auth?: {
|
||||
username: string
|
||||
password: string
|
||||
}
|
||||
domainName: string
|
||||
strategy: 'file' | 'http'
|
||||
origin: string
|
||||
fileServer: string
|
||||
props: Record<string, any>
|
||||
visiting: string
|
||||
}
|
||||
|
||||
interface Backend {
|
||||
/**
|
||||
* Firefox only: Force Cypress to run garbage collection routines.
|
||||
@@ -982,7 +995,7 @@ declare namespace Cypress {
|
||||
* .its('contentType')
|
||||
* .should('eq', 'text/html')
|
||||
*/
|
||||
document(options?: Partial<Loggable>): Chainable<Document>
|
||||
document(options?: Partial<Loggable & Timeoutable>): Chainable<Document>
|
||||
|
||||
/**
|
||||
* Iterate through an array like structure (arrays or objects with a length property).
|
||||
@@ -1958,7 +1971,7 @@ declare namespace Cypress {
|
||||
*
|
||||
* @see https://on.cypress.io/title
|
||||
*/
|
||||
title(options?: Partial<Loggable>): Chainable<string>
|
||||
title(options?: Partial<Loggable & Timeoutable>): Chainable<string>
|
||||
|
||||
/**
|
||||
* Trigger an event on a DOM element.
|
||||
@@ -2060,7 +2073,7 @@ declare namespace Cypress {
|
||||
* @alias cy.location('href')
|
||||
* @see https://on.cypress.io/url
|
||||
*/
|
||||
url(options?: Partial<Loggable & Timeoutable>): Chainable<string>
|
||||
url(options?: Partial<UrlOptions>): Chainable<string>
|
||||
|
||||
/**
|
||||
* Control the size and orientation of the screen for your application.
|
||||
@@ -2488,6 +2501,47 @@ declare namespace Cypress {
|
||||
cmdKey: boolean
|
||||
}
|
||||
|
||||
interface PEMCert {
|
||||
/**
|
||||
* Path to the certificate file, relative to project root.
|
||||
*/
|
||||
cert: string
|
||||
/**
|
||||
* Path to the private key file, relative to project root.
|
||||
*/
|
||||
key: string
|
||||
/**
|
||||
* Path to a text file containing the passphrase, relative to project root.
|
||||
*/
|
||||
passphrase?: string
|
||||
}
|
||||
|
||||
interface PFXCert {
|
||||
/**
|
||||
* Path to the certificate container, relative to project root.
|
||||
*/
|
||||
pfx: string
|
||||
/**
|
||||
* Path to a text file containing the passphrase, relative to project root.
|
||||
*/
|
||||
passphrase?: string
|
||||
}
|
||||
|
||||
interface ClientCertificate {
|
||||
/**
|
||||
* URL to match requests against. Wildcards following [minimatch](https://github.com/isaacs/minimatch) rules are supported.
|
||||
*/
|
||||
url: string
|
||||
/**
|
||||
* Paths to one or more CA files to validate certs against, relative to project root.
|
||||
*/
|
||||
ca?: string[]
|
||||
/**
|
||||
* A PEM format certificate/private key pair or PFX certificate container
|
||||
*/
|
||||
certs: PEMCert[] | PFXCert[]
|
||||
}
|
||||
|
||||
interface ResolvedConfigOptions {
|
||||
/**
|
||||
* Url used as prefix for [cy.visit()](https://on.cypress.io/visit) or [cy.request()](https://on.cypress.io/request) command’s url
|
||||
@@ -2750,6 +2804,11 @@ declare namespace Cypress {
|
||||
* @default {}
|
||||
*/
|
||||
e2e: Omit<ResolvedConfigOptions, TestingType>
|
||||
|
||||
/**
|
||||
* An array of objects defining the certificates
|
||||
*/
|
||||
clientCertificates: ClientCertificate[]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2810,19 +2869,15 @@ declare namespace Cypress {
|
||||
projectName: string
|
||||
projectRoot: string
|
||||
proxyUrl: string
|
||||
remote: RemoteState
|
||||
report: boolean
|
||||
reporterRoute: string
|
||||
reporterUrl: string
|
||||
socketId: null | string
|
||||
socketIoCookie: string
|
||||
socketIoRoute: string
|
||||
spec: {
|
||||
absolute: string
|
||||
name: string
|
||||
relative: string
|
||||
specFilter: null | string
|
||||
specType: 'integration' | 'component'
|
||||
}
|
||||
spec: Cypress['spec'] | null
|
||||
specs: Array<Cypress['spec']>
|
||||
xhrRoute: string
|
||||
xhrUrl: string
|
||||
}
|
||||
@@ -3173,6 +3228,18 @@ declare namespace Cypress {
|
||||
eventConstructor: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Options to change the default behavior of .url()
|
||||
*/
|
||||
interface UrlOptions extends Loggable, Timeoutable {
|
||||
/**
|
||||
* Whether the url is decoded
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
decode: boolean
|
||||
}
|
||||
|
||||
/** Options to change the default behavior of .writeFile */
|
||||
interface WriteFileOptions extends Loggable {
|
||||
flag: string
|
||||
@@ -5263,7 +5330,7 @@ declare namespace Cypress {
|
||||
tag?: string
|
||||
}
|
||||
|
||||
interface DevServerOptions {
|
||||
interface DevServerConfig {
|
||||
specs: Spec[]
|
||||
config: ResolvedConfigOptions & RuntimeConfigOptions
|
||||
devServerEvents: NodeJS.EventEmitter
|
||||
@@ -5282,7 +5349,7 @@ declare namespace Cypress {
|
||||
(action: 'before:spec', fn: (spec: Spec) => void | Promise<void>): void
|
||||
(action: 'before:browser:launch', fn: (browser: Browser, browserLaunchOptions: BrowserLaunchOptions) => void | BrowserLaunchOptions | Promise<BrowserLaunchOptions>): void
|
||||
(action: 'file:preprocessor', fn: (file: FileObject) => string | Promise<string>): void
|
||||
(action: 'dev-server:start', fn: (file: DevServerOptions) => Promise<ResolvedDevServerConfig>): void
|
||||
(action: 'dev-server:start', fn: (file: DevServerConfig) => Promise<ResolvedDevServerConfig>): void
|
||||
(action: 'task', tasks: Tasks): void
|
||||
}
|
||||
|
||||
|
||||
@@ -497,6 +497,11 @@ namespace CypressLocationTests {
|
||||
cy.location('pathname') // $ExpectType Chainable<string>
|
||||
}
|
||||
|
||||
// https://github.com/cypress-io/cypress/issues/17399
|
||||
namespace CypressUrlTests {
|
||||
cy.url({decode: true}).should('contain', '사랑')
|
||||
}
|
||||
|
||||
namespace CypressBrowserTests {
|
||||
Cypress.isBrowser('chrome')// $ExpectType boolean
|
||||
Cypress.isBrowser('firefox')// $ExpectType boolean
|
||||
|
||||
Reference in New Issue
Block a user