cypress-if icon indicating copy to clipboard operation
cypress-if copied to clipboard

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

Open alhajiry opened this issue 2 years ago • 11 comments

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.

alhajiry avatar Aug 16 '23 14:08 alhajiry

The same question. Any updates?

triori avatar Mar 08 '24 14:03 triori

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

bahmutov avatar Mar 08 '24 15:03 bahmutov

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.

triori avatar Mar 20 '24 03:03 triori

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

bahmutov avatar Mar 25 '24 23:03 bahmutov

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

triori avatar Apr 06 '24 05:04 triori

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.

d86inbox avatar Apr 08 '24 18:04 d86inbox

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

Roddied avatar Apr 08 '24 20:04 Roddied

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

vushatov avatar Apr 09 '24 08:04 vushatov

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

bee-beast avatar Apr 09 '24 16:04 bee-beast

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

bahmutov avatar Apr 09 '24 16:04 bahmutov

@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?

triori avatar Jul 21 '24 17:07 triori