aboutsummaryrefslogtreecommitdiffhomepage
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md86
1 files changed, 4 insertions, 82 deletions
diff --git a/README.md b/README.md
index 20c2fd6..4b24e2d 100644
--- a/README.md
+++ b/README.md
@@ -2,88 +2,10 @@
2 2
3A Node + Puppeteer base image for running Puppeteer scripts. Add your own tools (such as Jest, Mocha, etc), link services you want to test via Docker Compose, and run your Puppeteer scripts with a headless Chromium. 3A Node + Puppeteer base image for running Puppeteer scripts. Add your own tools (such as Jest, Mocha, etc), link services you want to test via Docker Compose, and run your Puppeteer scripts with a headless Chromium.
4 4
5See the list of [Docker Hub tags](https://hub.docker.com/r/buildkite/puppeteer/tags/) for Puppeteer versions available. 5## Versions
6
7## Usage example
8
9Dockerfile.integration-tests:
10
11```Dockerfile
12FROM buildkite/puppeteer:latest
13RUN npm i mocha
14ENV PATH="${PATH}:/node_modules/.bin"
15```
16
17docker-compose.integration-tests.yml:
18
19```yml
20version: '3'
21services:
22 tests:
23 build:
24 context: .
25 dockerfile: Dockerfile.integration-tests
26 volumes:
27 - "./integration-tests:/integration-tests"
28 - "/screenshots"
29 command: mocha --recursive /integration-tests
30 links:
31 - app
32 app:
33 image: tutum/hello-world
34 expose:
35 - "80"
36```
37
38integration-tests/index.test.js:
39
40```js
41const assert = require('assert')
42const puppeteer = require('puppeteer')
43 6
44let browser 7See the list of [Docker Hub tags](https://hub.docker.com/r/buildkite/puppeteer/tags/) for Puppeteer versions available.
45let page
46
47before(async() => {
48 browser = await puppeteer.launch({
49 args: [
50 // Required for Docker version of Puppeteer
51 '--no-sandbox',
52 '--disable-setuid-sandbox',
53 // This will write shared memory files into /tmp instead of /dev/shm,
54 // because Docker’s default for /dev/shm is 64MB
55 '--disable-dev-shm-usage'
56 ]
57 })
58
59 const browserVersion = await browser.version()
60 console.log(`Started ${browserVersion}`)
61})
62
63beforeEach(async() => {
64 page = await browser.newPage()
65})
66
67afterEach(async() => {
68 await page.close()
69})
70
71after(async() => {
72 await browser.close()
73})
74
75describe('App', () => {
76 it('renders', async() => {
77 const response = await page.goto('http://app/')
78 assert(response.ok())
79 await page.screenshot({ path: `/screenshots/app.png` })
80 })
81})
82```
83 8
84Running: 9## Example
85 10
86```shell 11See the [example directory](example) for a complete Docker Compose example, showing how to run Puppeteer against a linked Docker Compose web service.
87docker-compose -f docker-compose.integration-tests.yml run tests
88ls screenshots/
89```