Skip to content
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

Support adding custom messages from consoleProps #184

Closed
steinybot opened this issue May 12, 2023 · 2 comments
Closed

Support adding custom messages from consoleProps #184

steinybot opened this issue May 12, 2023 · 2 comments

Comments

@steinybot
Copy link

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[]);
@archfz
Copy link
Owner

archfz commented May 13, 2023

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.

@archfz
Copy link
Owner

archfz commented May 27, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants