Skip to content

Commit

Permalink
Merge branch 'develop' into 9.0-release
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbreiding authored Aug 5, 2021
2 parents 2e4ec7c + bc4df1e commit b01f8f8
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 12 deletions.
7 changes: 7 additions & 0 deletions npm/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [@cypress/react-v5.9.3](https://github.com/cypress-io/cypress/compare/@cypress/react-v5.9.2...@cypress/react-v5.9.3) (2021-08-03)


### Bug Fixes

* plugin for next 11.0.2 moved webpack-config ([#17529](https://github.com/cypress-io/cypress/issues/17529)) ([130c086](https://github.com/cypress-io/cypress/commit/130c0864e786ae5172f2c70fdc86664dcaf93083)), closes [#17519](https://github.com/cypress-io/cypress/issues/17519) [#17476](https://github.com/cypress-io/cypress/issues/17476)

# [@cypress/react-v5.9.2](https://github.com/cypress-io/cypress/compare/@cypress/react-v5.9.1...@cypress/react-v5.9.2) (2021-07-20)


Expand Down
7 changes: 7 additions & 0 deletions npm/vite-dev-server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [@cypress/vite-dev-server-v2.0.5](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.0.4...@cypress/vite-dev-server-v2.0.5) (2021-08-04)


### Bug Fixes

* reload every spec file when support updated ([#17598](https://github.com/cypress-io/cypress/issues/17598)) ([efc38b6](https://github.com/cypress-io/cypress/commit/efc38b67497b48db5b3a636acac3be45dd930593))

# [@cypress/vite-dev-server-v2.0.4](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.0.3...@cypress/vite-dev-server-v2.0.4) (2021-07-31)


Expand Down
19 changes: 12 additions & 7 deletions npm/vite-dev-server/src/makeCypressPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ const INIT_FILEPATH = resolve(__dirname, '../client/initCypressTests.js')

const HMR_DEPENDENCY_LOOKUP_MAX_ITERATION = 50

function getSpecsPathsSet (specs: Spec[], supportFile?: string | null) {
function getSpecsPathsSet (specs: Spec[]) {
return new Set<string>(
supportFile
? [...specs.map((spec) => spec.absolute), supportFile]
: specs.map((spec) => spec.absolute),
specs.map((spec) => spec.absolute),
)
}

Expand All @@ -42,10 +40,10 @@ export const makeCypressPlugin = (
): Plugin => {
let base = '/'

let specsPathsSet = getSpecsPathsSet(specs, supportFilePath)
let specsPathsSet = getSpecsPathsSet(specs)

devServerEvents.on('dev-server:specs:changed', (specs: Spec[]) => {
specsPathsSet = getSpecsPathsSet(specs, supportFilePath)
specsPathsSet = getSpecsPathsSet(specs)
})

const posixSupportFilePath = supportFilePath ? convertPathToPosix(resolve(projectRoot, supportFilePath)) : undefined
Expand Down Expand Up @@ -106,8 +104,15 @@ export const makeCypressPlugin = (
// as soon as we find one of the specs, we trigger the re-run of tests
for (const mod of moduleImporters.values()) {
debug('handleHotUpdate - mod.file', mod.file)
if (mod.file === supportFilePath) {
debug('handleHotUpdate - support compile success')
devServerEvents.emit('dev-server:compile:success')

return []
}

if (mod.file && specsPathsSet.has(mod.file)) {
debug('handleHotUpdate - compile success')
debug('handleHotUpdate - spec compile success', mod.file)
devServerEvents.emit('dev-server:compile:success', { specFile: mod.file })

return []
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cypress",
"version": "8.1.0",
"version": "8.2.0",
"description": "Cypress.io end to end testing tool",
"private": true,
"scripts": {
Expand Down
30 changes: 30 additions & 0 deletions packages/driver/cypress/integration/cypress/proxy-logging-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,34 @@ describe('Proxy Logging', () => {
})
})
})

context('Cypress.ProxyLogging', () => {
describe('.logInterception', () => {
it('creates a fake log for unmatched requests', () => {
const interception = {
id: 'request123',
request: {
url: 'http://foo',
method: 'GET',
headers: {},
},
}

const route = {}

const ret = Cypress.ProxyLogging.logInterception(interception, route)

expect(ret.preRequest).to.deep.eq({
requestId: 'request123',
resourceType: 'other',
originalResourceType: 'Request with no browser pre-request',
url: 'http://foo',
method: 'GET',
headers: {},
})

expect(ret.log.get('name')).to.eq('request')
})
})
})
})
18 changes: 14 additions & 4 deletions packages/driver/src/cypress/proxy-logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,18 +270,26 @@ export class ProxyLogging {
/**
* Update an existing proxy log with an interception, or create a new log if one was not created (like if shouldLog returned false)
*/
logInterception (interception: Interception, route: Route): ProxyRequest | undefined {
logInterception (interception: Interception, route: Route): ProxyRequest {
const unloggedPreRequest = take(this.unloggedPreRequests, ({ requestId }) => requestId === interception.browserRequestId)

if (unloggedPreRequest) {
debug('interception matched an unlogged prerequest, logging %o', { unloggedPreRequest, interception })
this.createProxyRequestLog(unloggedPreRequest)
}

const proxyRequest = _.find(this.proxyRequests, ({ preRequest }) => preRequest.requestId === interception.browserRequestId)
let proxyRequest = _.find(this.proxyRequests, ({ preRequest }) => preRequest.requestId === interception.browserRequestId)

if (!proxyRequest) {
throw new Error(`Missing pre-request/proxy log for cy.intercept to ${interception.request.url}`)
// this can happen in a race condition, if user runs Network.disable, if the browser doesn't send pre-request for some reason...
debug(`Missing pre-request/proxy log for cy.intercept to ${interception.request.url} %o`, { interception, route })

proxyRequest = this.createProxyRequestLog({
requestId: interception.browserRequestId || interception.id,
resourceType: 'other',
originalResourceType: 'Request with no browser pre-request',
..._.pick(interception.request, ['url', 'method', 'headers']),
})
}

proxyRequest.interceptions.push({ interception, route })
Expand Down Expand Up @@ -349,12 +357,14 @@ export class ProxyLogging {
this.createProxyRequestLog(preRequest)
}

private createProxyRequestLog (preRequest: BrowserPreRequest) {
private createProxyRequestLog (preRequest: BrowserPreRequest): ProxyRequest {
const proxyRequest = new ProxyRequest(preRequest)
const logConfig = getRequestLogConfig(proxyRequest as Omit<ProxyRequest, 'log'>)

proxyRequest.log = this.Cypress.log(logConfig).snapshot('request')

this.proxyRequests.push(proxyRequest as ProxyRequest)

return proxyRequest
}
}

0 comments on commit b01f8f8

Please sign in to comment.