Overview
The Forgejo project uses Playwright for testing its codebase. However, Playwright does not work on non-Debian-based Linux distributions. The usual workaround is to spin up a VM, but this consumes many resources and slows down your machine.
I couldn’t find any Docker image that solves this problem. Although the solution is simple, no one seems to have addressed it yet. So, I created a Docker image based on the official Playwright image specifically for testing Forgejo.
I created a Docker image based on Playwright’s official image with all prerequisites installed, so we can mount the project directory at runtime to run Forgejo test cases without copying the project into the image.
Playwright Setup
Checkout the official README.md written for
e2etesting.
- Pull the Docker Image:
docker pull iamyaash8/playwright-forgejo:v1.54.2.1-noble
- Change directory into the Forgejo project and run the container in interactive mode:
cd forgejo/
docker run -it --rm -v .:/home/forgejo-tester/forgejo iamyaash8/playwright-forgejo:v1.54.2.1-noble
Inside the Container
Run this commands to install playwright and it’s dependencies:
npx playwright install-deps && npx playwright install
The files inside ~/forgejo are owned by the root user of the running container, which in this case is ubuntu (both username & groupname). Make sure to change the ownership of the files to $USER. In this container, the user forgejo-tester.
sudo chown -R forgejo-tester:forgejo-tester *
Note: Make sure to execute this command again outside the container to revert the ownership back to the user after terminating the container.
Interactive Testing (recommended):
Ensure you completed the above mentioned setup
make test-e2e-debugserver
This command runs a forgejo instance locally, which already comes with dummy data to run tests on it. Playwright will be running tests on the local Forgejo instance that is currently running.
In case you see this error:
sed -e 's|{{REPO_TEST_DIR}}||g' \
-e 's|{{TEST_LOGGER}}|test,file|g' \
-e 's|{{TEST_TYPE}}|e2e|g' \
tests/sqlite.ini.tmpl > tests/sqlite.ini
GITEA_ROOT="/home/iamyaash/Projects/codeberg/forgejo" GITEA_CONF=tests/sqlite.ini ./e2e.sqlite.test -test.run TestDebugserver -test.timeout 24h
Could not find gitea binary at /home/iamyaash/Projects/codeberg/forgejo/gitea
make: *** [Makefile:697: test-e2e-debugserver] Error 1
It’s looking for a binary named gitea, which would have been built during the previously required build step. However, you can skip that step by using this workaround:
touch gitea && sudo chmod 744 gitea
Running Test
You can run the “full test suite”:
make test-e2e-sqlitemake test-e2e-mysql # when using mySQL databasemake test-e2e-pgsql # when using PostgreSQL databaseYou can run individual tests:
npx playwright test tests/e2e/pr-review.test.e2e.ts npx playwright test tests/e2e/* # run e2e tests only # it's flexible to use it the way you want