Skip to content

Instantly share code, notes, and snippets.

@pskopek
Created April 2, 2025 13:16
Show Gist options
  • Save pskopek/de9d79cf0511839dd5c97703be5cc624 to your computer and use it in GitHub Desktop.
Save pskopek/de9d79cf0511839dd5c97703be5cc624 to your computer and use it in GitHub Desktop.
Playwright compatible distrobox setup on Fedora 41

Setup on Fedora 41 (or other not supported Linux distro)

Playwright doesn't support Fedora distribution. Following is a description how to run the tests using Ubuntu 22.04 image using distrobox which is fairy supported on various Linux distributions.

Install distrobox and podman packages

sudo dnf install distrobox podman

Create home directory for your distrobox environment. It is useful not to mess with your host system home directory.

mkdir ~/distrobox

Create distrobox container environment to run tests

This command creates container using podman in your host. For more information see the documentation.

distrobox create \
--name pw --image ubuntu:22.04 \
--home ~/distrobox  \
--root \
--additional-packages "podman libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2 libxtst6 xauth xvfb" \
--unshare-all \
--absolutely-disable-root-password-i-am-really-positively-sure

Note

The last option of the previous command is not necessary. If avoided one will be asked for password used in sudo command in the container. One can enter the created distrobox environment using:

distrobox enter --root pw

Install nodejs in the newly created environment

We recommend to use Nodesource to help you with the nodejs setup in the container.

Enter the container using:

distrobox enter --root pw

Download and run the setup for nodejs on Ubuntu installation:

curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt-get install nodejs -y

This made nodejs environment setup complete.

Next is to install playwright and run the test.

npx playwright install
npm test
@sokqa
Copy link

sokqa commented Aug 23, 2025

Hi! Thanks for the guide. This is the first time I'm using distrobox. I've played around with create based on this page (though using Ubuntu 24.04), and I have the following remarks:

  • Rather than adding all those packages one by one, I put nodejs and npm (and git and vim) after --additional-packages. npx playwright install-deps then takes care of the rest, it works and it makes the create command more readable.
  • Nothing that I encountered so far about Playwright required host root privileges. I definitely recommend omitting --absolutely-disable-root-password-i-am-really-positively-sure, because using it is highly discouraged in the documentation, and also --root, simply because it is not needed.
  • When I run npx playwright test the framework automatically hosts the test report at localhost:9323, inside the distrobox, of course. The --unshare-all flag disables network sharing, making the localhost of the box unavailable from the host. Since I didn't want to install a browser in this box to look at the report, I enabled network sharing by omitting this flag as well. I have no concerns about shared resources right now but it is possible to control those resources separately (so introducing some of the specific unshare options while removing unshare-all).

This is how my create command looks after all that:

distrobox create \
--name ubuntu --image ubuntu:24.04 \
--home /home/me/distrobox-ubuntu \
--additional-packages "git vim nodejs npm"

Once created, I navigate to my project, go npx playwright install-deps as mentioned before, then npx playwright test.
This approach seems simpler to me, it's free of discouraged bad practices, and it's working, so I wanted to share it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment