Skip to content

Commit

Permalink
feat: add page.screenshot options
Browse files Browse the repository at this point in the history
  • Loading branch information
dferber90 committed Sep 23, 2018
1 parent 1751e60 commit ef4de3d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This package will only give you the image, you'll have to diff it with something
- [Usage](#usage)
- [Options](#options)
- [`options.launch`](#-optionslaunch-)
- [`options.screenshot`](#-optionsscreenshot-)
- [`options.debug`](#-optionsdebug-)
- [`options.viewport`](#-optionsviewport-)
- [`options.waitForResources`](#-optionswaitforresources-)
Expand Down Expand Up @@ -53,8 +54,10 @@ generateImage(component, options);

```js
options = {
// Options that are passed to Puppeteer (puppeteer.launch(options))
// Options used to launch Puppeteer (puppeteer.launch(options))
launch: {},
// Options used to take a screenshot (puppeteer.screenshot(options))
screenshot: {},
// Prints the jsdom markup to the console before taking the screenshot
debug: true,
// Wait for resources to be loaded before taking the screenshot
Expand All @@ -68,7 +71,11 @@ options = {

#### `options.launch`

`launch` are passed to `puppeteer.launch([options])`, see [`docs`](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunch).
`launch` options are passed to `puppeteer.launch([options])`, see [`docs`](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunch).

#### `options.screenshot`

`screenshot` options are passed to `page.screenshot([options])`, see [`docs`](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagescreenshotoptions).

#### `options.debug`

Expand Down
5 changes: 3 additions & 2 deletions generateImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ const takeScreenshot = async (html, opts) => {
await page.setContent(html);
}

const image = await page.screenshot();
const image = await page.screenshot(opts.screenshot);
browser.close();

return image;
};

const defaultOpts = {
waitForResources: true,
launch: {}
launch: {},
screenshot: undefined
};

const generateImage = async options => {
Expand Down

0 comments on commit ef4de3d

Please sign in to comment.