Skip to content

Instantly share code, notes, and snippets.

@kevinashworth
Last active November 16, 2020 20:17
Show Gist options
  • Save kevinashworth/f785eddea368af71c28701c223dd2d03 to your computer and use it in GitHub Desktop.
Save kevinashworth/f785eddea368af71c28701c223dd2d03 to your computer and use it in GitHub Desktop.
Cypress command to select an option when using react-select-virtualized
// 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