fix: don't inherit default message for request logging (#28411)

This commit is contained in:
Matt Schile
2023-11-28 09:21:06 -07:00
committed by GitHub
parent 650d5cb7da
commit d5678c794f
3 changed files with 23 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ _Released 12/5/2023 (PENDING)_
**Bugfixes:**
- Fixed an issue where pages or downloads opened in a new tab were missing basic auth headers. Fixes [#28350](https://github.com/cypress-io/cypress/issues/28350).
- Fixed an issue where request logging would default the `message` to the `args` of the currently running command even though those `args` would not apply to the request log and are not displayed. If the `args` are sufficiently large (e.g. when running the `cy.task` from the [code-coverage](https://github.com/cypress-io/code-coverage/) plugin) there could be performance/memory implications. Addressed in [#28411](https://github.com/cypress-io/cypress/pull/28411).
## 13.6.0

View File

@@ -126,6 +126,27 @@ describe('Proxy Logging', () => {
img.src = `/fixtures/media/cypress.png?${Date.now()}`
})
it('does not inherit the message of the currently running command', () => {
const logs: any[] = []
cy.on('log:added', (log) => {
if (log.name !== 'request') return
logs.push(log)
})
// delay the fetch call by 100ms to ensure it gets
// triggered during the cy.wait() below
setTimeout(() => {
fetch('/some-url')
}, 100)
cy.wait(200).then(() => {
expect(logs).to.have.length(1)
expect(logs[0].message).to.eq('')
})
})
context('with cy.intercept()', () => {
it('shows non-xhr/fetch log if intercepted', (done) => {
const src = `/fixtures/media/cypress.png?${Date.now()}`

View File

@@ -67,6 +67,7 @@ function getRequestLogConfig (req: Omit<ProxyRequest, 'log'>): Partial<Cypress.I
url: req.preRequest.url,
method: req.preRequest.method,
timeout: 0,
message: '', // set to empty string so that we don't inherit the default message
consoleProps: () => req.consoleProps,
renderProps: () => {
function getIndicator (): 'aborted' | 'pending' | 'successful' | 'bad' {