Skip to content

Commit

Permalink
fix: disable lcd text
Browse files Browse the repository at this point in the history
closes #1
  • Loading branch information
dferber90 committed Sep 23, 2018
1 parent 672a144 commit 66bc6d5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions generateImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ const puppeteer = require("puppeteer");
const merge = require("lodash.merge");
const debug = require("./debug");

const addArg = (opts, arg) => {
if (!Array.isArray(opts.launchOptions.args)) opts.launchOptions.args = [];

if (!opts.launchOptions.args.includes(arg)) {
opts.launchOptions.args.push(arg);
}
};

const takeScreenshot = async (html, opts) => {
// Options see:
// https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions
Expand Down Expand Up @@ -42,6 +50,11 @@ const generateImage = async options => {
opts.launchOptions.defaultViewport = options.viewport;
}

// Disable "lcd text antialiasing" to avoid differences in the snapshots
// depending on the used monitor.
// See https://github.com/dferber90/jsdom-screenshot/issues/1
addArg(opts, "--disable-lcd-text");

// Allows easy debugging by passing generateImage({ debug: true })
if (opts.debug) debug(document);

Expand Down

0 comments on commit 66bc6d5

Please sign in to comment.