Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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,
},
})
```
Expand Down
3 changes: 0 additions & 3 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
21 changes: 3 additions & 18 deletions src/modules/handleResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
Expand All @@ -218,7 +203,7 @@ export const handleResponse = (res: ApiResponseBody, options: ApiRequestOptions,
consoleProps() {
return {
yielded,
cURL: generateCurl()
cURL: generateCurl(props[index])
}
}
})
Expand All @@ -241,7 +226,7 @@ export const handleResponse = (res: ApiResponseBody, options: ApiRequestOptions,
consoleProps() {
return {
yielded,
cURL: generateCurl()
cURL: generateCurl(props[index])
}
}
})
Expand Down
11 changes: 7 additions & 4 deletions src/utils/shouldRenderUi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading