Connect Jest tests to Selenium WebDriver.
npm install --save-dev jest-environment-webdriver
Set testEnvironment
to jest-environment-webdriver
and select target browser using testEnvironmentOptions
:
"testEnvironment": "jest-environment-webdriver",
"testEnvironmentOptions": {
"browser": "safari"
}
Next global objects and functions are available in testing code.
browser
— reference to WebDriver
instanceby
— alias to By
element
— alias to Driver#findElement
element.all
— alias to Driver#findElements
until
— alias to until
.