


RUN chmod +x ci-run.sh Ĭi-run.sh looks something like this: #!/usr/bin/env bash # exit on error set -eĪfter installing all the dependencies we’re going to write some boilerplate code: // shared.js const puppeteer = require( 'puppeteer') Īrgs: , Libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \įonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst ttf-freefont \Ĭa-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget & \ĭpkg -i dumb-init_*.deb & rm -f dumb-init_*.deb & \Īpt-get clean & apt-get autoremove -y & rm -rf /var/lib/apt/lists/* WORKDIR.

Libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \ Libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \ MAINTAINER add # This is necessary to run Puppeteer on Docker RUN apt-get update & \Īpt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \ The docker image is pretty simple, we don’t need many things here FROM node: 10.15. I’m not using any library like jest-puppeteer because I like to have full control of my tests and I felt it was just too magical.Īll our tests are in docker/e2e-tests. We need to set up a few things before: Docker image, Jest and Puppeteer. You can of course test other cases such as if the file is larger than 1mb, for example. We’re going to test if we can successfully submit a file (Only the happy path for sake of brevity). Hope you’ll find this article useful :) Requirements I had to write something similar recently at work so I thought to extrapolate a few bits and pieces and share them with you. In this article I will show you how to test a web form that requires a file to be uploaded. You can use Puppeteer for many things like web scraping, pre-rendering SPA, taking screenshots, perform end-to-end tests etc. Puppeteer is a Node.js library built by the Chrome DevTools team that allows you to control headless Chrome.

How to use Puppeteer with Docker to test uploading a file to a web form
