Configure Docker for consistent end-to-end testing with Chroma
Docker provides a consistent testing environment for Chroma, ensuring tests run the same way locally and in CI. This guide shows you how to set up and use Docker with Chroma.
# Dockerfile for Chroma E2E Testing# This image is optimized for running Playwright tests with wallet extensionsFROM mcr.microsoft.com/playwright:v1.58.0-noble# Set environment variablesENV CI=trueENV DEBIAN_FRONTEND=noninteractiveENV DISPLAY=:99# Install unzip (required for Bun installation)RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/*# Install BunRUN curl -fsSL https://bun.sh/install | bashENV PATH="/root/.bun/bin:${PATH}"# Set working directoryWORKDIR /app# Copy package files first for better cachingCOPY package.json bun.lock ./COPY packages/chroma/package.json ./packages/chroma/COPY packages/e2e-polkadot-js/package.json ./packages/e2e-polkadot-js/COPY packages/e2e-evm/package.json ./packages/e2e-evm/# Install dependencies (ignore scripts as chroma isn't built yet)RUN bun install --ignore-scripts# Copy the rest of the source codeCOPY . .# Build the Chroma packageRUN cd packages/chroma && bun run build# Re-run install to link the chroma CLI bin after buildRUN bun install# Set working directory back to app rootWORKDIR /app# E2E_TARGET env var to specify which e2e package to test (required)# Examples: polkadot-js, evm, solana (will prepend e2e- automatically)ENV E2E_TARGET=""# Default command: prepare and run tests for specified E2E_TARGETCMD ["sh", "-c", "xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' -- sh -c 'cd /app/packages/e2e-$E2E_TARGET && bun run test:prepare && npx playwright test --reporter=html'"]
# Run Polkadot-JS testsdocker run --rm --shm-size=2gb -e E2E_TARGET=polkadot-js chroma-test# Run EVM testsdocker run --rm --shm-size=2gb -e E2E_TARGET=evm chroma-test
Always set --shm-size=2gb or higher. Chromium requires shared memory for multiprocess architecture. Without it, tests will crash.
docker run -it --rm --shm-size=2gb chroma-test bash
Inside the container:
# Navigate to your test packagecd packages/e2e-polkadot-js# Download extensionsbun run test:prepare# Run testsnpx playwright test# Run specific testnpx playwright test multi-wallet.spec.ts