mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-30 19:18:45 -06:00
fix: improve the performance of resetting the browser state by not resetting file_systems (#32703)
* fix: improve the performance of resetting the browser state by removing file_systems which is not something we need to reset * fix test * add changelog entry * fix electron * Apply suggestions from code review
This commit is contained in:
@@ -11,6 +11,7 @@ _Released 10/21/2025 (PENDING)_
|
||||
|
||||
- An error is no longer thrown during command execution when the application under test overwrites the `window.$` property with a non-function. Fixes [#1502](https://github.com/cypress-io/cypress/issues/1502). Fixed in [#32682](https://github.com/cypress-io/cypress/pull/32682).
|
||||
- When running `cypress` in Cypress development environments, or when `ELECTRON_ENABLE_LOGGING` is otherwise set to 1, certain messages written to `stderr` will no longer be bracketed with verbose tags. Addresses [#32569](https://github.com/cypress-io/cypress/issues/32569). Addressed in [#32674](https://github.com/cypress-io/cypress/pull/32674).
|
||||
- Improve performance of time between specs by not resetting the `file_systems` `StorageType` state when executing the CDP command `Storage.clearDataForOrigin`. Fixed in [#32703](https://github.com/cypress-io/cypress/pull/32703).
|
||||
|
||||
**Misc:**
|
||||
|
||||
|
||||
@@ -639,7 +639,9 @@ export class CdpAutomation implements CDPClient, AutomationMiddleware {
|
||||
})
|
||||
case 'reset:browser:state':
|
||||
return Promise.all([
|
||||
this.sendDebuggerCommandFn('Storage.clearDataForOrigin', { origin: '*', storageTypes: 'all' }),
|
||||
// Note that we are omitting `file_systems` as it is very non-performant to clear:
|
||||
// https://github.com/cypress-io/cypress/pull/32703
|
||||
this.sendDebuggerCommandFn('Storage.clearDataForOrigin', { origin: '*', storageTypes: 'cookies,indexeddb,local_storage,shader_cache,service_workers,cache_storage,interest_groups,shared_storage' }),
|
||||
this.sendDebuggerCommandFn('Network.clearBrowserCache'),
|
||||
])
|
||||
case 'reset:browser:tabs:for:next:spec':
|
||||
|
||||
@@ -341,7 +341,9 @@ export = {
|
||||
this._handleDownloads(win, options.downloadsFolder, automation),
|
||||
utils.initializeCDP(pageCriClient, automation),
|
||||
// Ensure to clear browser state in between runs. This is handled differently in browsers when we launch new tabs, but we don't have that concept in electron
|
||||
pageCriClient.send('Storage.clearDataForOrigin', { origin: '*', storageTypes: 'all' }),
|
||||
// Note that we are omitting `file_systems` as it is very non-performant to clear:
|
||||
// https://github.com/cypress-io/cypress/pull/32703
|
||||
pageCriClient.send('Storage.clearDataForOrigin', { origin: '*', storageTypes: 'cookies,indexeddb,local_storage,shader_cache,service_workers,cache_storage,interest_groups,shared_storage' }),
|
||||
pageCriClient.send('Network.clearBrowserCache'),
|
||||
])
|
||||
}
|
||||
|
||||
@@ -560,12 +560,12 @@ context('lib/browsers/cdp_automation', () => {
|
||||
|
||||
describe('reset:browser:state', function () {
|
||||
it('sends Storage.clearDataForOrigin and Network.clearBrowserCache', async function () {
|
||||
this.sendDebuggerCommand.withArgs('Storage.clearDataForOrigin', { origin: '*', storageTypes: 'all' }).resolves()
|
||||
this.sendDebuggerCommand.withArgs('Storage.clearDataForOrigin', { origin: '*', storageTypes: 'cookies,indexeddb,local_storage,shader_cache,service_workers,cache_storage,interest_groups,shared_storage' }).resolves()
|
||||
this.sendDebuggerCommand.withArgs('Network.clearBrowserCache').resolves()
|
||||
|
||||
await this.onRequest('reset:browser:state')
|
||||
|
||||
expect(this.sendDebuggerCommand).to.be.calledWith('Storage.clearDataForOrigin', { origin: '*', storageTypes: 'all' })
|
||||
expect(this.sendDebuggerCommand).to.be.calledWith('Storage.clearDataForOrigin', { origin: '*', storageTypes: 'cookies,indexeddb,local_storage,shader_cache,service_workers,cache_storage,interest_groups,shared_storage' })
|
||||
expect(this.sendDebuggerCommand).to.be.calledWith('Network.clearBrowserCache')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -517,7 +517,7 @@ describe('lib/browsers/electron', () => {
|
||||
it('expects the browser to be reset', function () {
|
||||
return electron._launch(this.win, this.url, this.automation, this.options, undefined, undefined, { attachCDPClient: sinon.stub() })
|
||||
.then(() => {
|
||||
expect(this.pageCriClient.send).to.be.calledWith('Storage.clearDataForOrigin', { origin: '*', storageTypes: 'all' })
|
||||
expect(this.pageCriClient.send).to.be.calledWith('Storage.clearDataForOrigin', { origin: '*', storageTypes: 'cookies,indexeddb,local_storage,shader_cache,service_workers,cache_storage,interest_groups,shared_storage' })
|
||||
expect(this.pageCriClient.send).to.be.calledWith('Network.clearBrowserCache')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user