Last active
          November 16, 2020 20:17 
        
      - 
      
- 
        Save kevinashworth/f785eddea368af71c28701c223dd2d03 to your computer and use it in GitHub Desktop. 
    Cypress command to select an option when using react-select-virtualized
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // declare in commands.js | |
| Cypress.Commands.add('chooseRSVOption', (selector, option) => { | |
| const re = new RegExp(`^${option}$`) // exact match | |
| cy.get(`${selector} .react-select-virtualized input`) | |
| .click({ force: true }) | |
| .type(option) | |
| .get('.fast-option') | |
| .contains(re) | |
| .click() | |
| }) | |
| // use in *.spec.js | |
| const selector = 'input-title' | |
| const option = 'President' | |
| cy.chooseRSVOption(selector, option) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment