Reputation: 109
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?
Upvotes: 2
Views: 7471
Reputation: 109
This problem was fixed by adding:
FROM mcr.microsoft.com/playwright:bionic
which added all the needed dependencies.
Upvotes: 1
Reputation: 13933
You can start from the provided image mcr.microsoft.com/playwright:v1.16.2-focal
:
FROM mcr.microsoft.com/playwright:v1.16.2-focal
# copy project files
COPY . /e2e
WORKDIR /e2e
# Install dependencies
RUN npm install
RUN npx playwright install
# Run playwright test
CMD [ "npx", "playwright", "test", "--reporter=list" ]
The --reporter=list
option is to print a line for each test being executed.
Upvotes: 0
Reputation: 3244
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:
COPY /root/.cache/ms-playwright/ /root/.cache/ms-playwright/
Upvotes: 2