aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTim Lucas <t@toolmantim.com>2019-02-06 10:57:32 +1100
committerTim Lucas <t@toolmantim.com>2019-02-06 11:31:33 +1100
commit40876fe8ad7b884004ed5f47ac66ce79b0e9ad14 (patch)
treed52fc6800d57d67ccd92f9b5af391fbae6093b9d
parent3a4b164295f12e232ec73ab052f2928c6a8b539c (diff)
downloaddocker-puppeteer-40876fe8ad7b884004ed5f47ac66ce79b0e9ad14.tar.gz
docker-puppeteer-40876fe8ad7b884004ed5f47ac66ce79b0e9ad14.tar.zst
docker-puppeteer-40876fe8ad7b884004ed5f47ac66ce79b0e9ad14.zip
Update README.md
-rw-r--r--README.md86
-rw-r--r--example/README.md17
2 files changed, 21 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```
diff --git a/example/README.md b/example/README.md
new file mode 100644
index 0000000..3f1c735
--- /dev/null
+++ b/example/README.md
@@ -0,0 +1,17 @@
1# Docker Puppeteer Example
2
3This as an example of using the Docker Puppeteer docker image to run Mocha tests against a linked Docker Compose web service, and capturing a screenshot into a local `./screenshots` directory.
4
5## Running
6
7```shell
8# Clone this example
9git clone https://github.com/buildkite/docker-puppeteer.git
10cd docker-puppeteer/example
11
12# Build and run the example tests
13docker-compose -f docker-compose.integration-tests.yml run tests
14
15# See the screen that was generated
16ls screenshots/
17```