https://cypress.io logo
Join Discord
Powered by
# general-chat
  • f

    fresh-doctor-14925

    11/28/2022, 3:45 PM
    !duplicate
  • n

    nutritious-analyst-96582

    11/28/2022, 3:45 PM
    Uh oh, It looks like you have posted the same question in multiple channels. Help us prevent spam by removing any duplicates of your questions, Thanks! 😀
  • b

    best-flower-17510

    11/28/2022, 5:46 PM
    I am asking internally regarding this question. Will follow up soon.
  • b

    best-flower-17510

    11/28/2022, 8:01 PM
    This issue was added to our priority list, you should see updates coming soon 😀
  • g

    green-summer-76342

    11/28/2022, 8:35 PM
    did you ever resolve this issue? I'm currently having the same issue.
  • e

    elegant-dog-90839

    11/29/2022, 10:30 AM
    Hey I have a general question about how cypress works under the hood, because to me it seems all my test code exceutes before the test starts and all cy commands are queued up by cypress and then executed. Is this how cypress works? This leads to some complications with my test set up, because I did not know .
  • i

    incalculable-rainbow-43330

    11/29/2022, 10:32 AM
    any alternative for cy.wait(TimeStamp) we tried to check for certain items to load and visible and also intercepts so any other suggesions to over come this timestamp ?
  • f

    fresh-doctor-14925

    11/29/2022, 10:58 AM
    > we tried to check for certain items to load and visible and also intercepts These are what I would suggest. Can you go into more detail around why they weren't helpful? If you have a video recording of what happens, I can try to make some suggestions
  • f

    fresh-doctor-14925

    11/29/2022, 10:59 AM
    This plugin can give you a better idea of how the chaining works in cypress https://github.com/bahmutov/cypress-command-chain
  • e

    elegant-dog-90839

    11/29/2022, 11:01 AM
    I am asking because I want to somehow wait for one process step to finish any Idea how I could do this?
    Copy code
    js
      /**
       * This is the essential run function that will run all steps.
       * It will look for the steps in tests/e2e/support/steps and either take customer specific steps or default steps.
       * the it loops over them and executes the connected function.
       */
      run() {
        this.prepareJourney();
        const steps = getSteps(Cypress.env('VUE_APP_ENVIRONMENT'));
        steps.forEach((step) => {
          cy.wait(Cypress.env('CY_WAIT_EXTRA_SHORT'));
          if (step.preProcess) {
            this[step.preProcess]();
          }
          if (step.process) {
            this[step.process]();
          }
          if (step.postProcess) {
            this[step.postProcess]();
          } else {
            this.postStepWait();
          }
        });
  • e

    elegant-dog-90839

    11/29/2022, 11:02 AM
    We have simple stepper application which is used by multiple clients. For every client we have rearranged the forms on each step and we have sometimes different forms but in the main sense we have always the same steps often just rearranged. SO what we did is that we have a step list for every client and in cypress testing we just want to iterate over that list. But cypress is not waiting on every process step it seems that it executes all process synchronously and the cypress commands are then just queued up somehow. This behaviour makes it impossible to have some conditional testing (unless we mock everything). The question is how can we actually stop the execution on every step.preProcess, step.process and step.postProcess and wait till the test code has finished
  • e

    elegant-dog-90839

    11/29/2022, 11:04 AM
    The steps list looks like this:
    Copy code
    js
        [{
            preProcess: null,
            process: 'chooseProduct',
            postProcess: null
        },
        {
            preProcess: null,
            process: 'personalForm',
            postProcess: null
        },]
  • f

    fresh-doctor-14925

    11/29/2022, 11:04 AM
    My hunch is that you need to wrap
    this.prepareJourney()
    So
    Copy code
    cy.wrap(this.prepareJourney())
      .then(() => {
        // the rest of what you're wanting to do
      })
    Copy code
    cy.wait(Cypress.env('CY_WAIT_EXTRA_SHORT'))
      .then(() => {
        // Conditional steps
      }
    Other than that, I recommend using the plugin to better understand chaining in Cypress and avoiding conditional testing wherever possible
  • e

    elegant-dog-90839

    11/29/2022, 11:05 AM
    @fresh-doctor-14925 okay I will try this thanks
  • e

    elegant-dog-90839

    11/29/2022, 11:06 AM
    I guess I will also need to wrap
    this[step.process]();
  • e

    elegant-dog-90839

    11/29/2022, 11:06 AM
    and then somehow built a chain
  • e

    elegant-dog-90839

    11/29/2022, 11:08 AM
    so basically I need to transform my list into this kinda chain:
    Copy code
    js
    cy.wrap(this[step.preProcess]()).then(()=> cy.wrap(this[step.process]()).then(...))
  • e

    elegant-dog-90839

    11/29/2022, 11:08 AM
    am I right?
  • e

    elegant-dog-90839

    11/29/2022, 11:09 AM
    Because I am doing some conditional testing, based on earlier steps
  • f

    fresh-doctor-14925

    11/29/2022, 11:11 AM
    I imagine it would be something like
    Copy code
    .then(() => {
          if (step.preProcess) {
            cy.wrap(this[step.preProcess]())
          }
          if (step.process) {
            cy.wrap(this[step.process]())
          }
          if (step.postProcess) {
            cy.wrap(this[step.postProcess]())
          } else {
            cy.wrap(this.postStepWait())
          }
      })
    But I would suggest not having conditionals if possible, and instead trying to control the starting state of your app As well, if any of these can be converted to cypress custom commands, you'll have an easier time with chaining
    e
    • 2
    • 6
  • e

    elegant-dog-90839

    11/29/2022, 11:12 AM
    hmm
  • e

    elegant-dog-90839

    11/29/2022, 11:12 AM
    okay thank you for your input
  • e

    elegant-dog-90839

    11/29/2022, 11:12 AM
    Sadly conditional testing is unavoidable here
  • e

    elegant-dog-90839

    11/29/2022, 11:13 AM
    due to lack of time we need to cover as much as possible for all clients
  • e

    elegant-dog-90839

    11/29/2022, 11:13 AM
    and they all come with different configs
  • e

    elegant-dog-90839

    11/29/2022, 11:13 AM
    and items to display etc.
  • f

    fresh-doctor-14925

    11/29/2022, 11:13 AM
    In that case, maybe this plugin will help you: https://github.com/bahmutov/cypress-if
  • e

    elegant-dog-90839

    11/29/2022, 11:14 AM
    This looks pretty awsome
  • e

    elegant-dog-90839

    11/29/2022, 11:14 AM
    thank you for the suggestion
  • f

    fresh-doctor-14925

    11/29/2022, 11:14 AM
    Yeah, the author recommends against conditional testing, but that's there if there's no alternative. Good luck!
1...969798...127Latest