'Sample DockerFile for playwright test

trying to dockerize my playwright test and having looking for some reference on how i can write the dockerfile. Did some searches but could not find much help. Could anyone share a sample that i can refer.

thanks



Solution 1:[1]

At the top of your Dockerfile you can put:

FROM mcr.microsoft.com/playwright:focal

followed by the code that executes your tests.

Check the docs here for more info.

Solution 2:[2]

Copy paste Dockerfile for those who have no idea how to use docker, source

FROM mcr.microsoft.com/playwright:focal

# copy project (including tests)
COPY . /e2e

WORKDIR /e2e

# Install dependencies
RUN npm install
# Install browsers
RUN npx playwright install

# Run playwright test
CMD [ "npx", "playwright", "test", "--reporter=list" ]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nico Mee
Solution 2 wanna_coder101