Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:DevExpress Testcafe Docker Xvfb Entry

From Leeroopedia
Knowledge Sources
Domains Testing, CI_CD, Web_Automation
Last Updated 2026-02-12 04:00 GMT

Overview

Docker entry script that configures Xvfb virtual display server for running TestCafe tests in containerized CI environments.

Description

This shell script serves as the Docker container entrypoint for TestCafe's official Docker image. It establishes a complete virtual display environment by starting Xvfb (X Virtual Frame Buffer) with configurable screen dimensions, launching the fluxbox window manager, initializing the D-Bus daemon for inter-process communication, and finally executing TestCafe with all passed arguments. The script uses environment variables for display configuration and redirects all background process output to /dev/null to keep logs clean.

Usage

This script is automatically invoked when running TestCafe Docker containers. It is used in:

  • CI/CD Pipelines: GitHub Actions, GitLab CI, Bitbucket Pipelines, Travis CI
  • Docker Compose: Multi-container test environments
  • Kubernetes: Test execution pods in cluster environments
  • Local Development: Consistent cross-platform testing via Docker

Code Reference

Source Location

  • Repository: testcafe
  • File: docker/testcafe-docker.sh
  • Lines: 1-9

Signature

#!/bin/sh
# Entry point script for TestCafe Docker container
# Accepts all TestCafe CLI arguments as script arguments

Import

# Used as Docker ENTRYPOINT in Dockerfile
# Usage: docker run -it testcafe/testcafe chromium tests/**/*.js

I/O Contract

Inputs

Name Type Required Description
$@ string[] No All TestCafe CLI arguments (browsers, test files, options)
SCREEN_WIDTH env int No Virtual display width in pixels (default: 1280)
SCREEN_HEIGHT env int No Virtual display height in pixels (default: 720)

Outputs

Name Type Description
DISPLAY env string Set to ":1.0" for Xvfb display
exit_code int TestCafe execution exit code (0 = success, non-zero = failures)

Usage Examples

Docker Run with Custom Resolution

docker run -it \
  -e SCREEN_WIDTH=1920 \
  -e SCREEN_HEIGHT=1080 \
  testcafe/testcafe chromium:headless tests/

GitHub Actions Workflow

# From .github/workflows/test-functional.yml
- run: |
    sudo apt install fluxbox
    Xvfb :99 -screen 0 1920x1080x24 &
    sleep 3
    fluxbox >/dev/null 2>&1 &
  env:
    DISPLAY: :99

Bitbucket Pipelines

# Uses Docker image with this script as entrypoint
image: testcafe/testcafe
pipelines:
  default:
    - step:
        script:
          - npm test  # Runs TestCafe inside container

Script Breakdown

#!/bin/sh
# 1. Set default dimensions if not provided
XVFB_SCREEN_WIDTH=${SCREEN_WIDTH-1280}
XVFB_SCREEN_HEIGHT=${SCREEN_HEIGHT-720}

# 2. Start D-Bus daemon for inter-process communication
dbus-daemon --session --fork

# 3. Start Xvfb on display :1 with specified resolution
Xvfb :1 -screen 0 "${XVFB_SCREEN_WIDTH}x${XVFB_SCREEN_HEIGHT}x24" >/dev/null 2>&1 &

# 4. Export DISPLAY variable for applications
export DISPLAY=:1.0

# 5. Start fluxbox window manager
fluxbox >/dev/null 2>&1 &

# 6. Execute TestCafe with all arguments
node /usr/local/lib/node_modules/testcafe/bin/testcafe-with-v8-flag-filter.js --ports 1337,1338 "$@"

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment