An Alternative Approach for Running TestCafe in a Lightweight Docker Container
This repository provides a Docker image for executing TestCafe tests. The goal is to streamline DEV and QA professionals testing workflows and enjoy the benefits of containerization.
Table of contents:
- README.md
- Dockerfile
- testcafe-alpine.sh
- tests/script.js
git clone https://github.com/afmpjr/testcafe-alpine.git && cd testcafe-alpine
docker build -t testcafe-alpine .
Use the follwing in case you have any network issue.
docker build --network host -t testcafe-alpine .
source ./testcafe-alpine.sh
or add to your .bashrc
, .zshrc
or wharever shell rc
you´re using by running the following from the directory where testcafe-alpine.sh
is located.
echo "source ${PWD}/testcafe-alpine.sh" >> "${HOME}/.$(basename "$SHELL")rc"
source ${HOME}/.$(basename "$SHELL")rc
# Runnin on multple browsers
testcafe -v ./:/testcafe/ firefox:headless,chromium:headless /testcafe/tests
# Runnin on Firefox + XML output
testcafe -v ./:/testcafe/ firefox:headless /testcafe/tests --reporter spec,xunit:/testcafe/report.xml
# Runnin on Chrome + JSON output
testcafe -v ./:/testcafe/ chromium:headless /testcafe/tests --reporter spec,json:/testcafe/report.json
# Getting the list of available browsers
testcafe --list-browsers
If you had any network issues on build
step, you'll probably have issues to run the image as well.
To solve that, update the testcafe-alpine.sh
by adding --network host
as follows:
local docker_command="docker run --network host -it --rm -v $(pwd):/testcafe/ testcafe-alpine testcafe ${extra_params[*]}"
If you’d like to help improving this project, feel free to:
- Fork the repository.
- Make your changes.
- Submit a pull request.