bahmutov / cypress-if

Easy conditional if-else logic for your Cypress tests when there is no other way
https://cypress.tips/courses/cypress-plugins
99 stars 12 forks source link

Unwanted log from cy.task when using cypress-if with cucumber-preprocessor #69

Open alhajiry opened 1 year ago

alhajiry commented 1 year ago

I noticed that when I import cypress-if to project that have cucumber-preprocessor from @badeball installed and then runs the test, Cypress will log something like this :

image

image

fyi : I don't use any hooks like Before, AfterEach, etc.

triori commented 8 months ago

The same question. Any updates?

bahmutov commented 8 months ago

Can you give me a small repo with a reproducible example?

triori commented 7 months ago

https://github.com/triori/badeball_cypress-if

This is a small repo with three of useless test. The modules and structure used are the same as in my work project. You can run it like npx cypress run and at the end of failed test log you can see

cy:command ✔  task        cypress-cucumber-preprocessor:test-step-finished, Object{4}
cy:command ✔  task        cypress-cucumber-preprocessor:test-case-finished, Object{3}
Screenshot 2024-03-19 at 23 04 48

This happens only with cypress-if module.

bahmutov commented 7 months ago

I don't see anything that is obviously wrong, and debugging this problem is beyond the time I have right now. Any help with this is appreciated

triori commented 7 months ago

I opened issue in the @badeball git hub, maybe his answer will be important.

https://github.com/badeball/cypress-cucumber-preprocessor/issues/1175#issuecomment-2040111626

d86inbox commented 7 months ago

I tried to use cypress-if, which looks amazing, solves a ton of problems, and gives much more flexibility, but I have the same problem with my logs. And now we are faced with a problem in our team. These logs greatly interfere with the use of this plugin. We have stopped its further implementation for now because we are trying to understand how much such logs complicate the daily work of the entire team. The question is about disconnection. Which I really wouldn’t want because this plugin is very useful.

Roddied commented 7 months ago

Started using cypress-if and it's amazing, but this issue makes extremely hard to analyze results. Is there any updates?

vushatov commented 7 months ago

I tried to use cypress-if, thanks for this update but I also have problems with the logs as mentioned here

bee-beast commented 7 months ago

While working with cypress-if, I faced the issue related to flooding of logs. I really don't want to break with cypress-if, but this problem is making my job very difficult

bahmutov commented 7 months ago

Sorry everyone, no updates, the https://github.com/triori/badeball_cypress-if repo is good, but there is way too much going on for me to immediately see the problem :( Anyone wants to look into it and find the root problem? I would be open to a PR with a fix

triori commented 3 months ago

@bahmutov unfortunately I don't have enough time for full investigation but in badeball module that I use, the log for some tasks is off:

function taskTestStepFinished(
  context: CompositionContext,
  testStepfinished: messages.TestStepFinished
) {
  if (context.isTrackingState) {
    cy.task(
      TASK_TEST_STEP_FINISHED,
      testStepfinished satisfies ITaskTestStepFinished,
      {
        log: false
      }
    );
  }
}

but you fully overwrite all kind of tasks:

Cypress.Commands.overwrite('task', function (task, args, options) {
    debug('cy.task %o', { args, options })

    const cmd = cy.state('current')
    if (cmd) {
      debug(cmd)
      const next = cmd.attributes.next

      if (isIfCommand(next)) {
        // disable the built-in assertion
        return task(args, options).then(
          (taskResult) => {
            debug('internal task result', taskResult)
            return taskResult
          },
          (error) => {
            debug('task error', error)
            cmd.attributes.error = error
          },
        )
      }
    }

    return task(args, options)
  })

Could it be the root of our problem?