title: Cypress - Timed out retrying after 4000ms: Expected to find element - only in Jenkins
body: <p>I have a grouping of Cypress tests that are failing, <em>only in my Jenkins environment</em>.  An entire <code>describe</code> block is failing to find an element.  Every test in the block starts with the same commands:</p>
  <pre class="lang-js prettyprint-override"><code>describe(&quot;This section of tests&quot;, () =&gt; {
    it(&quot;Test for something in this section&quot;, () =&gt; {
      cy.login(); // custom login command, works in all other test blocks
      setupPage(); // page setup function, no problems in all other test blocks
      cy.wait(10000); // desperation wait
  
      cy.get(&quot;#toggle-detail-pane-button&quot;).click(); // issue here!
      // all tests in block run more assertions and commands after this
    });
  
    // more similar tests in block
  });
  
  // more describe blocks that also use cy.login and setupPage, with no issue
  </code></pre>
  <p>When I run these tests in the cypress test UI, they all pass.  When I run them in the terminal on my machine with <code>npx cypress run</code>, they pass.  When I ssh into a remote OpenStack terminal which is set up to run my project and run cypress, and run <code>npx cypress run</code>, they pass.</p>
  <p>When I run the tests in Jenkins, which uses a handful of identical OpenStack instances to run cypress in parallel, the tests fail, consistently, with the following message:</p>
  <pre><code>AssertionError: Timed out retrying after 4000ms: Expected to find element: `#toggle-detail-pane-button`, but never found it.
  
        at Context.eval (http://localhost:3000/__cypress/tests?p=cypress/integration/stuff/mytests.spec.js:519:8)
  </code></pre>
  <p>I have tried reorganizing my tests, rewriting them, etc, but no luck.  I cannot figure out what is going wrong here.  My Jenkins environment uses a custom <a href="https://github.com/sorry-cypress/sorry-cypress" rel="noreferrer">sorry-cypress</a> setup, and for some reason, the dashboard is not registering the tests, so I can't go and view any screenshots or videos (that is a whole separate can-of-worms problem).</p>
  <p>Why would only these tests fail only in my CI/CD env?  How can I even begin to debug this?</p>
  <h3>Edit: screenshots</h3>
  <p>I was able to rerun the CI/CD with screenshots and videos, and then I was able to <code>scp</code> the files off of the instance with the failing tests.  When running on my machine, cypress has no problem finding the element:</p>
  <p><a href="https://i.stack.imgur.com/Ivj3a.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Ivj3a.png" alt="enter image description here" /></a></p>
  <p>When using the cypress selector playground on my machine, it finds it as well:</p>
  <p><a href="https://i.stack.imgur.com/Ena0H.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Ena0H.png" alt="enter image description here" /></a></p>
  <p>But in the screenshot I pulled off of the openstack instance running exactly the same test, it can't find it:</p>
  <p><a href="https://i.stack.imgur.com/qNgjQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qNgjQ.png" alt="enter image description here" /></a></p>
  <p><sub>(Sorry for all the green, this is a proprietary app)</sub></p>
  <p>What gives?</p>