diff --git a/README.md b/README.md index 989e75b..762bec3 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ You can control this with the `disableUi` option: - **unset (default):** render in open mode, skip in run mode. - **`true`:** always skip the UI (also speeds up open mode). -- **`false`:** always render, even in run mode (opt back into full Test Replay capture). +- **`false`:** same as unset (UI is still skipped in run mode). ```js it('my test', () => { @@ -102,8 +102,8 @@ export default defineConfig({ }, }, expose: { - // force the UI to render even in run mode - disableUi: false, + // Skip UI rendering (recommended for large responses / CI) + disableUi: true, }, }) ``` diff --git a/cypress.config.ts b/cypress.config.ts index dd4374b..bcd5239 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -6,9 +6,6 @@ export default defineConfig({ expose: { enableTimeline: true, requestMode: false, - // Force UI rendering even in run mode so the plugin's own UI tests work under `cypress run`. - // (By default the UI is skipped in run mode for performance — see disableUi.cy.ts.) - disableUi: false, }, allowCypressEnv: true, e2e: { diff --git a/src/modules/handleResponse.ts b/src/modules/handleResponse.ts index c126b49..2d78ad8 100644 --- a/src/modules/handleResponse.ts +++ b/src/modules/handleResponse.ts @@ -8,6 +8,7 @@ import { transform } from "@modules/transform"; import { getState } from '@utils/getState'; import { getPluginConfig } from '@utils/pluginConfig'; import { shouldRenderUi } from '@utils/shouldRenderUi'; +import { generateCurl } from '@utils/generateCurl'; import { App } from 'vue'; import { getFormat } from '@utils/getFormat'; import { isValidUrlOrIp } from '@utils/isValidUrlOrIp'; @@ -194,22 +195,6 @@ export const handleResponse = (res: ApiResponseBody, options: ApiRequestOptions, const yielded = res - const generateCurl = () => { - let curl = `curl -X ${options.method || 'GET'} "${options.url}"`; - if (options.headers) { - Object.entries(options.headers).forEach(([key, value]) => { - curl += ` -H "${key}: ${value}"`; - }); - } - if (options.body) { - if (typeof options.body === 'object') { - curl += ` -d '${JSON.stringify(options.body)}'`; - } else { - curl += ` -d '${options.body}'`; - } - } - return curl; - }; // No UI mounted: still log the request (with response/cURL in consoleProps), but skip // the DOM lookup, snapshot and scroll that only make sense with the rendered UI. @@ -218,7 +203,7 @@ export const handleResponse = (res: ApiResponseBody, options: ApiRequestOptions, consoleProps() { return { yielded, - cURL: generateCurl() + cURL: generateCurl(props[index]) } } }) @@ -241,7 +226,7 @@ export const handleResponse = (res: ApiResponseBody, options: ApiRequestOptions, consoleProps() { return { yielded, - cURL: generateCurl() + cURL: generateCurl(props[index]) } } }) diff --git a/src/utils/shouldRenderUi.ts b/src/utils/shouldRenderUi.ts index 9b7f8e4..709b54e 100644 --- a/src/utils/shouldRenderUi.ts +++ b/src/utils/shouldRenderUi.ts @@ -11,12 +11,15 @@ import { getPluginConfig } from './pluginConfig' * 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). + * - `false`: treated the same as `undefined` (UI is still skipped in run mode). */ export const shouldRenderUi = (): boolean => { + // Compliance/safety requirement: never render the full UI in run mode/CI. + if (Cypress.config('isInteractive') === false) return false + 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 + + // Open mode: render unless explicitly disabled. + return true }