title: Network requests are not always happening after click() command in cypress
body: <p>I am new to automation testing. I'm training to automate with cypress and I faced the problem that network requests (GET-XHR requests in particular) are not always being triggered after click() command in cypress.</p>
  <p>I have a custom command in my <code>/support/commands.js</code>, which is supposed to click 'Add to comparison' link and return the title of the item added to comparison:</p>
  <pre><code>Cypress.Commands.add(&quot;addToComparison&quot;, function (index) {
    cy.get(&quot;.vit-item&quot;).eq(index).find(&quot;.tovar-compare&quot;).click();
    return cy
      .get(&quot;.vit-item&quot;)
      .eq(index)
      .find(&quot;.vit-name&quot;)
      .invoke(&quot;text&quot;)
      .then((title) =&gt; {
        return title;
      });
  });
  </code></pre>
  <p>Then I call this command in my <code>/integration/smoke.spec.js:</code></p>
  <pre><code>describe(&quot;Add 2 items to comparison&quot;, () =&gt; {
    it(&quot;Add 2 items to comparison&quot;, () =&gt; {
      cy.visit(&quot;https://elmir.ua/cell_phones/&quot;);
      cy.addToComparison(0);
      cy.addToComparison(1);
      cy.get(&quot;#top-paging .compare-link&quot;).click();
    });
  });
  </code></pre>
  <p>When users do the same actions manually on the site, after clicking 'Add to comparison' link (<code>cy.get(&quot;.vit-item&quot;).eq(index).find(&quot;.tovar-compare&quot;).click()</code> in the <code>addToComparison</code> function), GET-request to  URL <code>https://elmir.ua/response/compare.php</code> is triggered, but when I run my test, the GET-request is being triggered from time to time, but almost never for both items in the test.
  <a href="https://i.stack.imgur.com/6vb3W.png" rel="nofollow noreferrer">Screenshot of Cypress test Runner</a></p>
  <p>I've tried chaining calls of <code>addToComparison()</code> with <code>then()</code> like this, but it did not make any difference:</p>
  <pre><code>describe(&quot;Add 2 items to comparison&quot;, () =&gt; {
    it(&quot;Add 2 items to comparison&quot;, () =&gt; {
      cy.visit(&quot;https://elmir.ua/cell_phones/&quot;);
      cy.addToComparison(0).then((item1) =&gt; {
        cy.addToComparison(1).then((item2) =&gt; {
          cy.get(&quot;#top-paging .compare-link&quot;).click();
        });
      });
    });
  });
  </code></pre>
  <p>Also, I've tried to avoid creating a custom function and just call <code>get()</code> method directly in the test, but it didn't make difference either:</p>
  <pre><code>describe(&quot;Add 2 items to comparison&quot;, () =&gt; {
    it(&quot;Add 2 items to comparison&quot;, () =&gt; {
      cy.visit(&quot;https://elmir.ua/cell_phones/&quot;);
      cy.get(&quot;.vit-item&quot;).eq(0).find(&quot;.tovar-compare&quot;).click();
      cy.get(&quot;.vit-item&quot;).eq(1).find(&quot;.tovar-compare&quot;).click();
      cy.get(&quot;#top-paging .compare-link&quot;).click();
    });
  });
  </code></pre>
  <p>The html snippet</p>
  <pre><code>&lt;li class=&quot;vit-item&quot;&gt;
    &lt;section class=&quot;vit-info&quot;&gt;
      &lt;a
        href=&quot;/cell_phones/mobile_phone_samsung_a207f_galaxy_a20s_32_duos_red_sm-a207fzrdsek.html&quot;
        class=&quot;vit-name&quot;
        &gt;Мобильный телефон Samsung A207F Galaxy A20s/32 Duos Red
        (SM-A207FZRDSEK)&lt;/a
      &gt;
      &lt;p class=&quot;vit-desc&quot;&gt;
        6,5&quot; / 720х1560 / IPS / ОЗУ - 3 ГБ / 32 ГБ встроенной памяти / Сканер
        отпечатка пальца / 4G / 2 SIM / 4000 мАч
      &lt;/p&gt;
      &lt;div class=&quot;vit-buy&quot;&gt;
        &lt;div class=&quot;btn-buy ready-1 status-1 buy-1000663 no-print&quot;&gt;
          &lt;div class=&quot;no-print ready btn&quot; onclick=&quot;btn_buy(1000663);&quot;&gt;
            &lt;svg&gt;&lt;use xlink:href=&quot;#v-basket&quot;&gt;&lt;/use&gt;&lt;/svg&gt;В корзину
          &lt;/div&gt;
          &lt;span class=&quot;status stat-1&quot;&gt;есть в наличии&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;span class=&quot;price vit-cost&quot;
        &gt;&lt;zl&gt;7&lt;/zl&gt;&lt;zj&gt;0&lt;/zj&gt;&lt;zf&gt;9&lt;/zf&gt;&lt;zy&gt;4&lt;/zy&gt;&lt;zf&gt;5&lt;/zf&gt;&lt;zr&gt;0&lt;/zr&gt;&lt;zb&gt;8&lt;/zb
        &gt;&lt;zu&gt;3&lt;/zu&gt;&lt;zx&gt;9&lt;/zx&gt;&lt;zv&gt;6&lt;/zv&gt;&lt;ze&gt;1&lt;/ze&gt;&lt;zz&gt;9&lt;/zz&gt;&lt;ze&gt;9&lt;/ze&gt;&lt;zo&gt;6&lt;/zo
        &gt;&lt;zu&gt;9&lt;/zu&gt;&amp;nbsp;грн&lt;/span
      &gt;&lt;br /&gt;&lt;span class=&quot;warr&quot;
        &gt;&lt;a target=&quot;_blank&quot; href=&quot;/faq.html#q17&quot;&gt;Гарантия:&lt;/a&gt;&amp;nbsp;12 мес.&lt;/span
      &gt;&lt;br /&gt;&lt;span
        product=&quot;1000663&quot;
        class=&quot;icon-eye view-rest internal-link link no-print&quot;
        &gt;&lt;svg&gt;&lt;use xlink:href=&quot;#v-avail&quot;&gt;&lt;/use&gt;&lt;/svg&gt;Посмотреть наличие&lt;/span
      &gt;&lt;br /&gt;&lt;a
        class=&quot;icon-mail notify no-print&quot;
        href=&quot;/?module=profile&amp;amp;tab=subscribe&amp;amp;add=1000663&quot;
        &gt;&lt;svg&gt;&lt;use xlink:href=&quot;#v-notify&quot;&gt;&lt;/use&gt;&lt;/svg&gt;Уведомить&lt;/a
      &gt;&lt;br /&gt;&lt;a
        class=&quot;icon-reviews no-print&quot;
        href=&quot;/cell_phones/mobile_phone_samsung_a207f_galaxy_a20s_32_duos_red_sm-a207fzrdsek.html#reviews&quot;
        &gt;&lt;svg&gt;&lt;use xlink:href=&quot;#v-reviews&quot;&gt;&lt;/use&gt;&lt;/svg&gt;Отзывы (0)&lt;/a
      &gt;&lt;br /&gt;&lt;span product=&quot;1000663&quot; class=&quot;tovar-wishlist no-print&quot;
        &gt;&lt;svg&gt;&lt;use xlink:href=&quot;#v-wish&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span
      &gt;&lt;br /&gt;&lt;span class=&quot;catalog-tovar-id&quot;&gt;Код товара: 1000663&lt;/span&gt;&lt;br /&gt;&lt;span
        compare_id=&quot;lg47&quot;
        parent_id=&quot;97516&quot;
        class=&quot;no-print tovar-compare add-link&quot;
        &gt;Добавить к сравнению&lt;/span
      &gt;
    &lt;/section&gt;
  &lt;/li&gt;
  </code></pre>
  <p>Usually only the first run of the test passes, but after I re-run the test the issue appears (but I'm not sure about that).</p>
  <p>I suppose I'm doing something terribly wrong, because this is not the only site where clicking the element does not trigger the GET XHR-request (well, I triggers, but only some of them). I tried another site with very similar logic and there was the same issue.</p>
  <p>Please help.</p>