You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's currently documented that you can run the Playwright server for tests inside a docker container if the host operating system is not supported. I think it would be great to expand on this and run the browser executable in a container, while the tests and server are run on the host.
This would involve Playwright using docker run <image> <browserExecutablePath> instead of launching the executable directly on the host.
Example
I wrote a wrapper, called Docketeer, around Puppeteer to do just this. I'd hope that doing the same for Playwright could be as simple as this:
PLAYWRIGHT_USE_DOCKER=true npx playwright test
This would automatically pick the docker image that matches the installed Playwright version.
Motivation
One could argue that running the browser in a Docker container is superior to running it on the host. It (almost) ensures that the environment will be identical regardless of the host platform. Indeed, for visual regression testing, the docs even point this out:
Warning
Browser rendering can vary based on the host OS, version, settings, hardware, power source (battery vs. power adapter), headless mode, and other >factors. For consistent screenshots, run tests in the same environment where the baseline screenshots were generated.
This generally means "run your tests in the same docker image that runs in CI". And it's awkward to do this right now. Some people are writing a custom Dockerfile, others are using docker run -v $(pwd):... sh -c 'npm install && npx playwright install && npx playwright test'. The latter can be a nightmare on a large monorepo, I'm typing up this feature request after PNPM decided it needed to recreate all the node_modules folders (and then Docker ran out of disk space, d'oh!). Having a super-easy way to ensure consistent rendering across platforms would be amazing.
In summary, this feature would offer the following benefits:
Minimizes or eliminates rendering differences between host environments
Reduced complexity (no need for Dockerfiles or docker build), easy to use the same environment in CI
Can replace npx playwright install, also means no dependencies need to be installed on the host
Fast performance (no need to map files into the container, no additional npm install required)
Package-manager independence (current Playwright docker images don't have PNPM/Yarn)
🚀 Feature Request
It's currently documented that you can run the Playwright server for tests inside a docker container if the host operating system is not supported. I think it would be great to expand on this and run the browser executable in a container, while the tests and server are run on the host.
This would involve Playwright using
docker run <image> <browserExecutablePath>instead of launching the executable directly on the host.Example
I wrote a wrapper, called Docketeer, around Puppeteer to do just this. I'd hope that doing the same for Playwright could be as simple as this:
This would automatically pick the docker image that matches the installed Playwright version.
Motivation
One could argue that running the browser in a Docker container is superior to running it on the host. It (almost) ensures that the environment will be identical regardless of the host platform. Indeed, for visual regression testing, the docs even point this out:
Warning
Browser rendering can vary based on the host OS, version, settings, hardware, power source (battery vs. power adapter), headless mode, and other >factors. For consistent screenshots, run tests in the same environment where the baseline screenshots were generated.
This generally means "run your tests in the same docker image that runs in CI". And it's awkward to do this right now. Some people are writing a custom Dockerfile, others are using
docker run -v $(pwd):... sh -c 'npm install && npx playwright install && npx playwright test'. The latter can be a nightmare on a large monorepo, I'm typing up this feature request after PNPM decided it needed to recreate all thenode_modulesfolders (and then Docker ran out of disk space, d'oh!). Having a super-easy way to ensure consistent rendering across platforms would be amazing.In summary, this feature would offer the following benefits:
docker build), easy to use the same environment in CInpx playwright install, also means no dependencies need to be installed on the hostnpm installrequired)