-
-
Notifications
You must be signed in to change notification settings - Fork 39
feat: skip UI rendering in run mode for performance #156
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
Open
filiphric
wants to merge
1
commit into
main
Choose a base branch
from
feat/disable-ui-run-mode
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| function setPluginConfig(key: string, value: unknown) { | ||
| const fn = (window as unknown as { setPluginConfig?: (k: string, v: unknown) => void }).setPluginConfig | ||
| if (typeof fn === 'function') fn(key, value) | ||
| else if (typeof (Cypress as unknown as { expose?: unknown }).expose === 'function') (Cypress as unknown as { expose: (k: string, v: unknown) => void }).expose(key, value) | ||
| else Cypress.env(key, value) | ||
| } | ||
|
|
||
| describe('disableUi mode', () => { | ||
|
|
||
| afterEach(() => { | ||
| // Restore the suite default (config forces UI on so other specs render). | ||
| setPluginConfig('disableUi', false) | ||
| }) | ||
|
|
||
| it('disableUi: true skips rendering the plugin UI but still yields the response', () => { | ||
| setPluginConfig('disableUi', true) | ||
| cy.api('/').then((res) => { | ||
| expect(res.status).to.eq(200) | ||
| }) | ||
| // No Vue app mounted and no response body rendered into the DOM. | ||
| cy.get('#api-plugin-root').should('not.exist') | ||
| cy.get('[data-cy="responseBody"]').should('not.exist') | ||
| }) | ||
|
|
||
| it('disableUi: false renders the UI even in run mode', () => { | ||
| setPluginConfig('disableUi', false) | ||
| cy.api('/') | ||
| cy.get('[data-cy="responseBody"]').should('be.visible') | ||
| }) | ||
|
|
||
| it('switching disableUi off again restores rendering', () => { | ||
| setPluginConfig('disableUi', true) | ||
| cy.api('/') | ||
| cy.get('[data-cy="responseBody"]').should('not.exist') | ||
|
|
||
| setPluginConfig('disableUi', false) | ||
| cy.api('/') | ||
| cy.get('[data-cy="responseBody"]').should('be.visible') | ||
| }) | ||
|
|
||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { getPluginConfig } from './pluginConfig' | ||
|
|
||
| /** | ||
| * Decide whether the plugin UI (Vue app + Prism syntax highlighting) should be rendered. | ||
| * | ||
| * Rendering the full UI is expensive: every cy.api() call syntax-highlights the entire | ||
| * request/response body and mounts it into the DOM, which Test Replay then captures. In | ||
| * run mode (`cypress run`/CI) the UI can't be interacted with, so this is pure overhead | ||
| * and can crash the browser renderer on large responses (see issue #135). | ||
| * | ||
| * Behaviour (controlled by the `disableUi` plugin option): | ||
| * - `undefined` (default): auto — render in open mode, skip in run mode. | ||
| * - `true`: always skip the UI (also helps open-mode performance). | ||
| * - `false`: always render, even in run mode (opt back into full Test Replay capture). | ||
| */ | ||
| export const shouldRenderUi = (): boolean => { | ||
| const disableUi = getPluginConfig('disableUi') | ||
| if (disableUi === true) return false | ||
| if (disableUi === false) return true | ||
| // Default: Cypress.config('isInteractive') is true in open mode and false in run mode. | ||
| return Cypress.config('isInteractive') !== false | ||
|
Comment on lines
+17
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. disableui: false enables run-mode ui shouldRenderUi() allows forcing full UI rendering in Cypress run mode when disableUi is explicitly set to false, which defeats the run-mode/CI safety requirement and can reintroduce renderer crashes/perf issues. The repo also configures disableUi: false in cypress.config.ts, causing UI rendering under cypress run. Agent Prompt
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5. Unsafe duplicate curl builder
🧑 Team insight⛨ SecurityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools