Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(intercept): add { log: false } to StaticResponse #25547

Merged
merged 16 commits into from
Mar 14, 2023
Merged
Prev Previous commit
Next Next commit
revert backend changes
  • Loading branch information
flotwig committed Jan 23, 2023
commit 0a2409af8efd569251eaa6cd3726734708c6b3b4
1 change: 0 additions & 1 deletion packages/net-stubbing/lib/internal-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const SERIALIZABLE_REQ_PROPS = [
'followRedirect',
'resourceType',
'query',
'log',
]

export const SERIALIZABLE_RES_PROPS = _.concat(
Expand Down
7 changes: 2 additions & 5 deletions packages/net-stubbing/lib/server/intercepted-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,11 @@ export class InterceptedRequest {
data,
}

// https://github.com/cypress-io/cypress/issues/17139
// Routes should be counted before they're sent.
if (eventName === 'before:request') {
const route = this.matchingRoutes.find(({ id }) => id === subscription.routeId) as BackendRoute

// To prevent users from accidentally setting `log: false` via fallthru, reset `req.log` on each interception.
this.req.log = !!(route.staticResponse?.log || this.req.log)

// https://github.com/cypress-io/cypress/issues/17139
// Routes should be counted before they're sent.
route.matches++

if (route.routeMatcher.times && route.matches >= route.routeMatcher.times) {
Expand Down
4 changes: 1 addition & 3 deletions packages/proxy/lib/http/request-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ const CorrelateBrowserPreRequest: RequestMiddleware = async function () {
}

const SendToDriver: RequestMiddleware = function () {
const { browserPreRequest, resourceType } = this.req

this.req.log = (resourceType === 'fetch' || resourceType === 'xhr')
const { browserPreRequest } = this.req

if (browserPreRequest) {
this.socket.toDriver('request:event', 'incoming:request', browserPreRequest)
Expand Down
4 changes: 0 additions & 4 deletions packages/proxy/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ export type CypressIncomingRequest = Request & {
proxiedUrl: string
abort: () => void
requestId: string
/**
* Should this request be logged in the Command Log?
*/
log?: boolean
browserPreRequest?: BrowserPreRequest
body?: string
responseTimeout?: number
Expand Down