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

enhancing the logging #50

Open
TobiasHH opened this issue Nov 9, 2024 · 4 comments
Open

enhancing the logging #50

TobiasHH opened this issue Nov 9, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@TobiasHH
Copy link
Contributor

TobiasHH commented Nov 9, 2024

Actual the usage of the mailpit logs directly the internal commands of the custom commands.

Cypress gives the possibility to use custom logging for custom commands so that the log gets more readable.

@pushpak1300 pushpak1300 added the enhancement New feature or request label Nov 12, 2024
@TobiasHH
Copy link
Contributor Author

please tell me when to implement

@pushpak1300
Copy link
Owner

Yes. @TobiasHH before implementing let's think a unify way to do logging in all the commands with minimal breaking change.

WhatI'm thinking there should be env variable by which we should control if we should log or not for all command instead of indiviual option.

The second thing is if we enable logging then what all things do you think we should log ?
The request, the response what exactly ?

@TobiasHH
Copy link
Contributor Author

Good question.

https://docs.cypress.io/api/cypress-api/cypress-log

Cypress.Commands.add('setSessionStorage', (key, value) => {
  // Turn off logging of the cy.window() to command log
  cy.window({ log: false }).then((window) => {
    window.sessionStorage.setItem(key, value)
  })

  const log = Cypress.log({
    name: 'setSessionStorage',
    // shorter name for the Command Log
    displayName: 'setSS',
    message: `${key}, ${value}`,
    consoleProps: () => {
      // return an object which will
      // print to dev tools console on click
      return {
        Key: key,
        Value: value,
        'Session Storage': window.sessionStorage,
      }
    },
  })
})

"WhatI'm thinking there should be env variable by which we should control if we should log or not for all command instead of indiviual option."

I don't think you need an env variable? The last time I added the parameter only to hide the internal called command.

	mailpitGetEmailsByTo(email: string, start = 0, limit = 50): Cypress.Chainable<MessagesSummary> {
		return this.mailpitSearchEmails(`to:${email}`, start, limit);
	}

this is displaying mailpitGetEmailsByTo and mailpitSearchEmails in the command log also if only mailpitGetEmailsByTo is called.

Cypress.Commands.add('setSessionStorage', (key, value) => {
  // Turn off logging of the cy.window() to command log
  cy.window({ log: false }).then((window) => {
    window.sessionStorage.setItem(key, value)
  })

Here you can see the log:false property so that the window command is not shown anymore when the setSessionStorage command is executed. The command log only displays setSessionStorage and not the internal window.

The console log I use only seldom.
I would log,

  • the input value like the Address, Subject, search
  • the Yielded Object like all Cypress commands do. i.e. MessagesSummary ...
  • maybe the messages count

I would not log the start, limit, timeout parameter

@TobiasHH
Copy link
Contributor Author

@pushpak1300 pushpak1300 self-assigned this Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants