I am trying to deploy my playwright automation framework in a docker container. However I assume that the browser won’t launch (don’t have any logs).
When I run my tests locally in VS code, they look like this:
When I run my tests in Docker container, they look like this:
It is clear that it is missing the [Google Chrome] or [chromium] at the beginning of the line. I assume that the browser is not getting launched.
My dockerfile looks like this:
# playwright:bionic has everything to run playwright (node, npm, chromium, dependencies)
#FROM mcr.microsoft.com/playwright:bionic
#COPY .. .
FROM node:14
FROM mcr.microsoft.com/playwright:focal
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package*.json /app/
#COPY features/ /app/features/
COPY src/ /app/src/
#COPY cucumber.js /app/
#COPY tsconfig.json /app/
#COPY reports/ /app/reports/
COPY *.config.json /app/
RUN npm install
RUN npx playwright install
CMD npm run test
#ENTRYPOINT ["npm run test"]
Any ideas how to get the tests to run in a container?
3
Answers
This problem was fixed by adding:
which added all the needed dependencies.
If not using the mcr.microsoft.com/playwright:bionic with all the dependencies, add this line after the
RUN npx playwright install
to get the browser binaries:You can start from the provided image
mcr.microsoft.com/playwright:v1.16.2-focal
:The
--reporter=list
option is to print a line for each test being executed.