busy-vegetable-18177
06/04/2022, 11:50 AMjs
Cypress.Commands.overwrite("click", (originalFn, subject, options) => {
  if (options !== undefined && options.scroll) {
    originalFn(subject, options)
  } else {
    cy.wrap(subject).should("be.in-viewport").then(() => originalFn(subject, options))
  }
})
But this gives me an error on another part of the code saying Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.
The command that returned the promise was:
  > cy.clear()
The cy command you invoked inside the promise was:
  > cy.wrap()
Because Cypress commands are already promise-like, you don't need to wrap them or return your own promise.
Cypress will resolve your command with whatever the final Cypress command yields.
I don't understand, what am I doing wrong? I'm not returning a promise...wonderful-match-15836
06/04/2022, 9:16 PMcy.click() and passing {scroll: false} ?
I like the custom assertion btw.busy-vegetable-18177
06/04/2022, 9:35 PMbusy-vegetable-18177
06/04/2022, 9:36 PMclick is probably the one on be.visible from before thatbusy-vegetable-18177
06/04/2022, 9:36 PMbusy-vegetable-18177
06/04/2022, 9:38 PMbusy-vegetable-18177
06/04/2022, 9:42 PMscroll: truebusy-vegetable-18177
06/04/2022, 9:44 PMbusy-vegetable-18177
06/04/2022, 9:46 PMbusy-vegetable-18177
06/04/2022, 9:46 PMwonderful-match-15836
06/04/2022, 9:52 PMcy.get("[data-cy-edit-form-name=Gunjo]").within(() => {
      cy.get("input[name=name]").clear().type("Gunjont") // <- here
    })busy-vegetable-18177
06/04/2022, 9:52 PMbusy-vegetable-18177
06/04/2022, 9:52 PMbusy-vegetable-18177
06/04/2022, 9:53 PMbusy-vegetable-18177
06/04/2022, 9:54 PMjs
    cy.visit("/")
    cy.get("input[name=search]").clear()wonderful-match-15836
06/04/2022, 9:54 PMclick in this way, I get the error. Which makes me think maybe clear is using clickbusy-vegetable-18177
06/04/2022, 9:54 PMwonderful-match-15836
06/04/2022, 9:54 PMclick internally to ensure the element you are typing into has focus, need to double checkbusy-vegetable-18177
06/04/2022, 9:55 PMbusy-vegetable-18177
06/04/2022, 9:56 PMwonderful-match-15836
06/04/2022, 9:57 PMclick , or make an internal private click that other commands use. Not sure what's best. But clear on a form field is an alias for  .type({selectall}{backspace}) so if click is invoked when you type it's also invoked when you clearwonderful-match-15836
06/04/2022, 10:05 PMclickIfInViewport or something to surface the fact this this does not behave the same way as cy.click() anyway, since new developers coming to your project with existing Cypress experience might not easily discover that you've implemented a different behavior.busy-vegetable-18177
06/04/2022, 10:07 PMbusy-vegetable-18177
06/04/2022, 10:07 PM