DON'T OVERLOOK THIS (needed for running tests without Docker)
- have browsers you want to test on installed
- have browser webdrivers in $PATH for browsers you want to test
WebDrivers:
- Chrome: https://sites.google.com/a/chromium.org/chromedriver/downloads
- Firefox: https://github.com/mozilla/geckodriver/releases
- Safari: in Terminal: safaridriver --enable
- Edge: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Pay close attention to the version. Edge and Chrome WebDrivers' versions must be the same as Edge/Chrome browser that is installed. For additional info: https://www.selenium.dev/downloads/
https://www.selenium.dev/selenium/docs/api/javascript/index.html
yarn init
yarn add jest selenium-webdriver typescript ts-jest
yarn add @types/jest @types/selenium-webdriver
npx jest --init
when asked if you want to use Typescript, choose NO
add->preset: "ts-jest",
<-to module.exports in jest.config.js
tsc --init
yarn
- WEBDRIVER
determines on which WebDriver to run tests
-
LOCATION
- defaults to nothing, which runs tests locally
remote
uses link inbuilder.ts
, requires changing
-
BINARIES
- defaults to nothing, which looks for default install location for used OS (ProgramFiles(and x86) for Windows or Applications for MacOS)
custom
uses path inbuilder.ts
, requires changing
-
UI
- defaults to nothing, which runs WebDriver in GUI mode
headless
runs browsers that have the capability (i.e. not Safari) in headless mode
CHECK
package.json -> scripts
FOR MORE DETAILS:
$env:WEBDRIVER="chrome"
$env:UI="headless"
yarn jest partOfANameOfTest(s)(suites)
MORE ON THIS: https://jestjs.io/docs/cli
yarn test:customBinaries:firefox partOfANameOfTest(s)(suites)
MORE ON THIS IN package.json
OR
BINARIES=custom WEBDRIVER=firefox yarn jest partOfANameOfTest(s)(suites)
Safari is special:
- can't headless
- always installed to default location
- haven't even tried to find remote runner so you'll have to add that case to builder.ts yourself
- WebDriver must not get out of focus so WebDrivers have to be run one by one
so for Safari it's:
yarn test:safari partOfANameOfTest(s)(suites)
OR
WEBDRIVER=safari yarn jest --maxWorkers=1 partOfANameOfTest(s)(suites)
-
Have Docker/Hub installed and running
-
Modify gridRouterAddress to wherever you are running the grid
-
Running tests is same as in above examples with few limitations depending on setup
- docker image has no browsers and webdrivers installed, it's just a test-caller and info-handler so
LOCATION=remote
is required,BINARIES
are most likely local, i.e. default and browsers can't be seen (or at least aren't taking focus) soUI
can be both default and headless with no practical difference for Grid 3 (hub and nodes) but has to beUI=headless
for Grid 4 (fully distributed)
- docker image has no browsers and webdrivers installed, it's just a test-caller and info-handler so
docker build path_to_dockerfile_in_project_dir -t name_of_the_image
docker run -it name_of_the_image
yarn test:headless:firefox partOfANameOfTesst(s)(suites)