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

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

Open
alhajiry opened this issue Aug 16, 2023 · 11 comments
Open
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@alhajiry
Copy link

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
Copy link
Contributor

triori commented Mar 8, 2024

The same question. Any updates?

@bahmutov
Copy link
Owner

bahmutov commented Mar 8, 2024

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

@bahmutov bahmutov added the question Further information is requested label Mar 8, 2024
@triori
Copy link
Contributor

triori commented Mar 20, 2024

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
Copy link
Owner

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
Copy link
Contributor

triori commented Apr 6, 2024

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

badeball/cypress-cucumber-preprocessor#1175 (comment)

@d86inbox
Copy link

d86inbox commented Apr 8, 2024

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
Copy link

Roddied commented Apr 8, 2024

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

@vushatov
Copy link

vushatov commented Apr 9, 2024

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

@bee-beast
Copy link

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
Copy link
Owner

bahmutov commented Apr 9, 2024

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
Copy link
Contributor

triori commented Jul 21, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants