For the following html,
<select class="cell dropdown" data-test="Visibility-warn">
<option value="">Select...</option>
<!---->
<option value="0"><!---->Good<!----></option>
<!---->
<option value="1"><!---->Moderate/Good<!----></option>
<!---->
<option value="2"><!---->Moderate<!----></option>
<!---->
<option value="3" selected=""><!---->Moderate/Poor<!----></option>
<!---->
<option value="4"><!---->Poor<!----></option>
<!---->
</select>
I have written the cypress code to select by value and not by text. As per docs, both select by text and select by value can be done in the same way.
cy.get('[data-test="Visibility-warn"]')
.should('be.enabled')
.select('3')
which works fine.
But on the other hand, I am trying to create a custom command that does not work.
cy.selectAndVerify('[data-test="Visibility-warn"]', weatherLimits.Visibility.warn, 'Moderate/Poor');
//weatherLimits.Visibility.warn = gives the value 3
And in Commands:
Cypress.Commands.add('selectAndVerify', (selector, textToSelect, valueToVerify) => {
cy.log(textToSelect)
cy.get(selector)
.should('be.enabled')
.select(textToSelect)
//.should('have.text', valueToVerify);
})
How can I possibly make the custom command work?

.select(textToSelect)?