mirror of
https://github.com/cypress-io/cypress.git
synced 2026-03-09 10:09:52 -05:00
This commit is contained in:
@@ -928,6 +928,22 @@ describe('network stubbing', function () {
|
||||
.wait('@dest')
|
||||
})
|
||||
|
||||
// @see https://github.com/cypress-io/cypress/issues/7967
|
||||
it('can skip redirects via followRedirect', function () {
|
||||
const href = `/fixtures/generic.html?t=${Date.now()}`
|
||||
const url = `/redirect?href=${encodeURIComponent(href)}`
|
||||
|
||||
cy.route2('/redirect', (req) => {
|
||||
req.followRedirect = true
|
||||
req.reply((res) => {
|
||||
expect(res.body).to.include('Some generic content')
|
||||
expect(res.statusCode).to.eq(200)
|
||||
res.send()
|
||||
})
|
||||
})
|
||||
.then(() => fetch(url))
|
||||
})
|
||||
|
||||
it('intercepts cached responses as expected', {
|
||||
browser: '!firefox', // TODO: why does firefox behave differently? transparently returns cached response
|
||||
}, function () {
|
||||
|
||||
@@ -39,6 +39,11 @@ export namespace CyHttpMessages {
|
||||
|
||||
export type IncomingRequest = BaseMessage & {
|
||||
responseTimeout?: number
|
||||
/**
|
||||
* Set if redirects should be followed when this request is made. By default, requests will
|
||||
* not follow redirects before yielding the response (the 3xx redirect is yielded)
|
||||
*/
|
||||
followRedirect?: boolean
|
||||
}
|
||||
|
||||
export interface IncomingHttpRequest extends IncomingRequest {
|
||||
|
||||
@@ -19,6 +19,7 @@ export const SERIALIZABLE_REQ_PROPS = [
|
||||
'method',
|
||||
'httpVersion',
|
||||
'responseTimeout',
|
||||
'followRedirect',
|
||||
]
|
||||
|
||||
export const SERIALIZABLE_RES_PROPS = _.concat(
|
||||
@@ -89,6 +90,7 @@ export declare namespace NetEventFrames {
|
||||
// Millisecond timestamp for when the response should continue
|
||||
continueResponseAt?: number
|
||||
throttleKbps?: number
|
||||
followRedirect?: boolean
|
||||
}
|
||||
|
||||
// fired when a response has been sent completely by the server to an intercepted request
|
||||
|
||||
@@ -103,7 +103,7 @@ const SendRequestOutgoing: RequestMiddleware = function () {
|
||||
const requestOptions = {
|
||||
timeout: this.req.responseTimeout,
|
||||
strictSSL: false,
|
||||
followRedirect: false,
|
||||
followRedirect: this.req.followRedirect || false,
|
||||
retryIntervals: [0, 100, 200, 200],
|
||||
url: this.req.proxiedUrl,
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ export type CypressIncomingRequest = Request & {
|
||||
requestId: string
|
||||
body?: string
|
||||
responseTimeout?: number
|
||||
followRedirect?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user