Skip to content

An alternative approach for running TestCafe as a Docker container

Notifications You must be signed in to change notification settings

afmpjr/testcafe-alpine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TestCafe (Alpine) Docker

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

Pre-requisites

How to use (Linux or WSL)

1. Clone this repo

git clone https://github.com/afmpjr/testcafe-alpine.git && cd testcafe-alpine

2. Build the image

docker build -t testcafe-alpine .

Use the follwing in case you have any network issue.

docker build --network host -t testcafe-alpine .

3. Enable the testcafe-alpine.sh script

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

4. Make sure you have tests in your tests directory

5. Run the tests

# 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[*]}"

Official TestCafe documentation

Open to Contributors

If you’d like to help improving this project, feel free to:

  • Fork the repository.
  • Make your changes.
  • Submit a pull request.

About

An alternative approach for running TestCafe as a Docker container

Topics

Resources

Stars

Watchers

Forks