cd pytest
# Run all tests on local dev server
pytest
# Run specific tests
# pytest <path_to_test_file> -k <test_name>
pytest test/test_discover_screen.py -k 'test_scan_feature'
# Run tests on specific platform(s)
# pytest --platform=[platform(s)]
pytest --platform=firefox,chrome,safari,ios,android
# Run tests against url other than localhost
# (e.g. when testing inside VM against server outside VM)
pytest --url="https://192.168.178.87:3000"
Chrome tests can be run locally on any operating system. Simply download and install the chromedriver and selenium will autodiscover the driver.
Firefox tests can be run locally on any operating system. Simply download and install the geckodriver and selenium will autodiscover the driver.
Safari tests can only be run on MacOS. The safari driver comes pre-installed so there should be no further configuration necessary. Currently, Safari does not support using fake devices for media streams, hence we cannot test for everything.
Android tests can be run on any operating system. First download and install Android Studio and the latest Android SDK. You will also need to download selendroid
The Android tests can also be run on a real Android device, once it's plugged in to your development machine via USB.
iOS tests can only be run on MacOS. Download and Install Xcode to enable the iOS emulator. The emulator has the limitation that
The e2e tests for the scanning feature have to be run inside a virtual machine, because the webcam needs to be faked. If you haven't set up the fake webcam, follow these instructions. In the future we will provide a VM image you can use out of the box.
# 1. Install v4l2loopback kernel module and v4l-utils from apt
sudo apt install v4l2loopback-dkms v4l-utils
# 2. Enable the "fake webcam", via v4l2loopback kernel module
sudo modprobe v4l2loopback devices=1 card_label="scan-test-webcam" exclusive_caps=1
# Install ffmpeg
sudo apt-get install ffmpeg
# Link video file (on loop) to the "fake webcam"
ffmpeg -stream_loop -1 -re -i ./test_scan_video.mp4 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video2
pytest test/test_discover_screen.py -k 'test_scan_feature' --platform=firefox --url="https://192.168.178.87:3000"
Adapted from: https://stackoverflow.com/questions/31859459/how-can-i-pass-a-fake-media-stream-to-firefox-from-command-line