jest-playwright-preset-example's People
jest-playwright-preset-example's Issues
Docker
Here's a Dockerfile that installs all the browser dependencies and sets browser options that chromium needs to run in a virtualized environment like docker. Note that in order for the individual browser builds to work, you have to update package.json to use at least jest-playwright-preset version 0.0.11 because otherwise npm install
will download all the browsers.
# Usage:
# Build the image with
# docker build -t jestplaywright .
# Or to build with just a specific browser, like chromium:
# docker build --target chromium -t jestplaywright:chromium .
# Note: With current docker version, 19.x, you have to enable building with BuildKit
# in order for --target to skip intermediate/unrelated stages. Set the env variable DOCKER_BUILDKIT=1 before building.
# Run your tests with:
# docker run -it --rm -v <path_to_your_jest_tests>:/home/node/__tests__ jestplaywright:<tag>
# Note: In order for the browser instances to find your app's server, you have at least 3 options:
# 1) In your tests, use `await page.goto('http://host.docker.internal:3000/');` (replace 3000 with your app's port).
# 2) Use docker-compose, and in your tests, use `await page.goto('http://app:3000/');` (replace app with your app's name in the compose file, and 3000 with your app's port).
# 3) Create a temporary network and add your app and jestplaywright to it, and in your tests, use `await page.goto('http://app:3000/');` (replace app with your app's name, and 3000 with your app's port).
FROM ubuntu:bionic AS base
# Setup a non-root user called "node", with home dir at /home/node
RUN groupadd --gid 1000 node \
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
# Install node and npm by adding its dep repo to apt's sources.
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl gnupg \
&& curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
&& echo 'deb https://deb.nodesource.com/node_13.x bionic main' > /etc/apt/sources.list.d/nodesource.list \
&& echo 'deb-src https://deb.nodesource.com/node_13.x bionic main' >> /etc/apt/sources.list.d/nodesource.list \
&& apt-get update && apt-get install -y --no-install-recommends nodejs \
&& echo "Node version: $(node --version)" && echo "NPM version: $(npm --version)" \
&& rm -rf /var/lib/apt/lists/*
# Install browser deps
RUN apt-get update && apt-get install -y --no-install-recommends \
libasound2 libatk-bridge2.0-0 libatk1.0-0 libcups2 libdbus-glib-1-2 libegl1 libegl1 \
libenchant1c2a libevent-2.1-6 libgdk-pixbuf2.0-0 libgl1 libgles2 libgtk-3-0 libgudev-1.0-0 \
libhyphen0 libnotify4 libnss3 libopus0 libpangocairo-1.0-0 libsecret-1-0 libvpx5 libwebp6 \
libwebpdemux2 libwoff1 libxcomposite1 libxcursor1 libxi6 libxrandr2 libxslt1.1 libxss1 libxt6 libxtst6 \
&& rm -rf /var/lib/apt/lists/*
USER node
# Set app directory
WORKDIR /home/node
COPY . .
VOLUME [ "/home/node/__tests__" ]
CMD [ "npm", "test" ]
FROM base AS chromium
RUN sed -i 's/browsers: \[\x27chromium\x27, \x27firefox\x27, \x27webkit\x27\]/browsers: [\x27chromium\x27],\n launchBrowserApp: { \n dumpio: true, \n args: [\x27--disable-dev-shm-usage\x27, \x27--disable-setuid-sandbox\x27, \x27--no-sandbox\x27] \n }/' jest-playwright.config.js
RUN sed -i 's/"playwright"/"playwright-chromium"/' package.json
RUN npm install
FROM base AS firefox
RUN sed -i 's/browsers: \[\x27chromium\x27, \x27firefox\x27, \x27webkit\x27\]/browsers: [\x27firefox\x27],\n launchBrowserApp: { \n dumpio: true \n }/' jest-playwright.config.js
RUN sed -i 's/"playwright"/"playwright-firefox"/' package.json
RUN npm install
FROM base AS webkit
RUN sed -i 's/browsers: \[\x27chromium\x27, \x27firefox\x27, \x27webkit\x27\]/browsers: [\x27webkit\x27],\n launchBrowserApp: { \n dumpio: true \n }/' jest-playwright.config.js
RUN sed -i 's/"playwright"/"playwright-webkit"/' package.json
RUN npm install
FROM base AS latest
RUN sed -i 's/browsers: \[\x27chromium\x27, \x27firefox\x27, \x27webkit\x27\]/browsers: [\x27chromium\x27, \x27firefox\x27, \x27webkit\x27],\n launchBrowserApp: { \n dumpio: true, \n args: [\x27--disable-dev-shm-usage\x27, \x27--disable-setuid-sandbox\x27, \x27--no-sandbox\x27] \n }/' jest-playwright.config.js
RUN npm install
It could be optimized a bit more, but it's good enough to run tests in individual browsers or all three.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.