title: How to create a custom select command to select by option value in cypress
body: <p>For the following html,</p>
  <pre><code>             &lt;select class=&quot;cell dropdown&quot; data-test=&quot;Visibility-warn&quot;&gt;
                  &lt;option value=&quot;&quot;&gt;Select...&lt;/option&gt;
                  &lt;!----&gt;
                  &lt;option value=&quot;0&quot;&gt;&lt;!----&gt;Good&lt;!----&gt;&lt;/option&gt;
                  &lt;!----&gt;
                  &lt;option value=&quot;1&quot;&gt;&lt;!----&gt;Moderate/Good&lt;!----&gt;&lt;/option&gt;
                  &lt;!----&gt;
                  &lt;option value=&quot;2&quot;&gt;&lt;!----&gt;Moderate&lt;!----&gt;&lt;/option&gt;
                  &lt;!----&gt;
                  &lt;option value=&quot;3&quot; selected=&quot;&quot;&gt;&lt;!----&gt;Moderate/Poor&lt;!----&gt;&lt;/option&gt;
                  &lt;!----&gt;
                  &lt;option value=&quot;4&quot;&gt;&lt;!----&gt;Poor&lt;!----&gt;&lt;/option&gt;
                  &lt;!----&gt;
              &lt;/select&gt;
  </code></pre>
  <p>I have written the cypress code to select by value and not by text. <em>As per <a href="https://docs.cypress.io/api/commands/select#Value" rel="nofollow noreferrer">docs</a>, both select by text and select by value can be done in the same way.</em></p>
  <pre><code>        cy.get('[data-test=&quot;Visibility-warn&quot;]')
                  .should('be.enabled')
                  .select('3')
  </code></pre>
  <p>which works fine.</p>
  <p>But on the other hand, I am trying to create a custom command that does not work.</p>
  <pre><code> cy.selectAndVerify('[data-test=&quot;Visibility-warn&quot;]', weatherLimits.Visibility.warn, 'Moderate/Poor');
   //weatherLimits.Visibility.warn = gives the value 3
  </code></pre>
  <p>And in Commands:</p>
  <pre><code>Cypress.Commands.add('selectAndVerify', (selector, textToSelect, valueToVerify) =&gt; {
    cy.log(textToSelect)
    cy.get(selector)
      .should('be.enabled')
      .select(textToSelect)
    //.should('have.text', valueToVerify);
  })
  </code></pre>
  <p>How can I possibly make the custom command work?</p>
  <p><a href="https://i.stack.imgur.com/U45oy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U45oy.png" alt="enter image description here" /></a></p>