Support adding custom messages from consoleProps
steinybot opened this issue · 2 comments
There are certain command which have a ton of really important information in the consoleProps
, especially on failures. Often the message is totally useless.
For example:
cy:command ✘ assert unexpected call to console.error: expected **[ Array(12) ]** to be empty
The consoleProps.actual
has the actual array contents which needs to be logged to have any hope of knowing what went wrong.
I've had to come up with an extremely convoluted solution which involves registering my own task to collect these props and then proxy the on: PluginEvents
argument that gets passed toinstallLogsPrinter
to append messages. It's really fragile and doesn't put the messages in the correct place, they are always on the end.
I'm not entirely sure what properties will be guaranteed but it could look something a bit like this:
additionalLogs?:
(options: InternalLogConfig) => Log[]
Or the consoleProps
could be added to Log
and change processLog
to:
type Log = [/* type: */ LogType, /* message: */ string, /* severity: */ Severity, /* consoleProps: */ ObjectLike];
processLog?:
| null
| NonNullable<SupportOptions['collectTypes']>[number]
| ((args: Log) => Log | Log[]);
Why not improve this in logging in the plugin by default. We could expand these values by default and maybe add some configs to control their sizes (maybe also have default limits). Contribution is welcome.
Added support for this in 5.2.0. But it is not customizable for now, and only the case of the assert
command is handled specially, meaning now it logs the expected
and the actual
objects with JSON.stringify
. Cypress was also including these in the message, but was truncating them given they were too big.