From: Tim Lucas Date: Tue, 5 Feb 2019 23:56:07 +0000 (+1100) Subject: Add more example files X-Git-Tag: v1.12.3~2^2~4 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=3a4b164295f12e232ec73ab052f2928c6a8b539c;p=github%2Ffretlink%2Fdocker-puppeteer.git Add more example files --- diff --git a/example/Dockerfile.integration-tests b/example/Dockerfile.integration-tests new file mode 100644 index 0000000..41de685 --- /dev/null +++ b/example/Dockerfile.integration-tests @@ -0,0 +1,3 @@ +FROM buildkite/puppeteer:latest +RUN npm i mocha +ENV PATH="${PATH}:/node_modules/.bin" \ No newline at end of file diff --git a/example/integration-tests/index.test.js b/example/integration-tests/index.test.js new file mode 100644 index 0000000..dd39d8a --- /dev/null +++ b/example/integration-tests/index.test.js @@ -0,0 +1,41 @@ +const assert = require('assert') +const puppeteer = require('puppeteer') + +let browser +let page + +before(async() => { + browser = await puppeteer.launch({ + args: [ + // Required for Docker version of Puppeteer + '--no-sandbox', + '--disable-setuid-sandbox', + // This will write shared memory files into /tmp instead of /dev/shm, + // because Docker’s default for /dev/shm is 64MB + '--disable-dev-shm-usage' + ] + }) + + const browserVersion = await browser.version() + console.log(`Started ${browserVersion}`) +}) + +beforeEach(async() => { + page = await browser.newPage() +}) + +afterEach(async() => { + await page.close() +}) + +after(async() => { + await browser.close() +}) + +describe('App', () => { + it('renders', async() => { + const response = await page.goto('http://app/') + assert(response.ok()) + await page.screenshot({ path: `/screenshots/app.png` }) + }) +}) \ No newline at end of file