feat: better I.grab logging in live interactive mode#4986
feat: better I.grab logging in live interactive mode#4986kobenguyent merged 3 commits intocodeceptjs:3.xfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR improves the logging output in live interactive mode by formatting the output of I.grab commands with JSON.stringify.
- Improved logging by converting the logged value to a JSON string with indentation.
- Enhances clarity during debugging sessions in interactive mode.
Add try/catch Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR improves the interactive shell logging during I.grab* commands by stringifying the output, thereby providing clearer and more readable terminal output during live sessions.
- Enhanced readability of interactive shell logs by applying JSON.stringify to the result
- Added error handling to catch potential JSON stringification failures
| } | ||
| if (cmd?.startsWith('I.grab')) { | ||
| output.print(output.styles.debug(val)) | ||
| try { |
There was a problem hiding this comment.
[nitpick] Consider adding a comment here to explain that JSON.stringify is applied to handle various output types for improved readability.
| try { | |
| try { | |
| // Use JSON.stringify to format the output for improved readability, especially for complex objects. |
There was a problem hiding this comment.
Pull Request Overview
This PR addresses a bug where interactive logging produced uninformative output and replaces it with JSON stringified output for better readability.
- Adds a try-catch block around JSON.stringify in I.grab command logging
- Improves error reporting during JSON conversion failures
Comments suppressed due to low confidence (1)
lib/pause.js:181
- [nitpick] Consider logging additional error context (such as the full error stack) to improve debugging when JSON.stringify fails.
output.print(output.styles.error(' ERROR '), 'Failed to stringify result:', err.message)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Motivation/Description of the PR
Currently, the interactive shell mode with pause() resulting output like:
[Object object]....this is clearly not useful during live interactive mode when we're using:I.grabBrowserLogs();or
I.grabRecordedNetworkTraffics();By json stringify the value, we can safely see every type of output in the terminal session like following.

Applicable helpers:
Applicable plugins:
Type of change
Checklist:
npm run docs)npm run lint)npm test)